I recently looked into the /creature_script function.
It looks like we can add any script in the correct folder (StarMade\data\script)
Select the concerned NPC with F, and type /creature_script "thescriptyouwant"
npc-trading-guild.lua is the shop's NPC spawner script (usefull to buy troops in your own base).
So I wanted to edit a script to set the dialog options I want for NPCs (bar, guards, workers). But this is quite painful. For now, I just have a template of script: the NPC has a text dialog when you press R on him, and a button to leave dialog AND it actually works ^^. It have one variable: the NPC's name. There may be more I don't know. I just kept this one from the existing script.
Here is the script.
This a bartender's dialog. Just edit this part to make him say whatever you want:
"Bonsoir, client.\n" ..
"Je m'apelle ".. dialogObject:getConverationParterName() ..".\n"..
"Ce sera quoi?"..
"\n"
Write only between the " and the \n are return to line.
It looks like we can add any script in the correct folder (StarMade\data\script)
Select the concerned NPC with F, and type /creature_script "thescriptyouwant"
npc-trading-guild.lua is the shop's NPC spawner script (usefull to buy troops in your own base).
So I wanted to edit a script to set the dialog options I want for NPCs (bar, guards, workers). But this is quite painful. For now, I just have a template of script: the NPC has a text dialog when you press R on him, and a button to leave dialog AND it actually works ^^. It have one variable: the NPC's name. There may be more I don't know. I just kept this one from the existing script.
Here is the script.
Code:
function create(dialogObject, bindings)
dSysClass = luajava.bindClass( "org.schema.game.common.data.player.dialog.DialogSystem" );
dSysFactoryClass = luajava.bindClass( "org.schema.game.common.data.player.dialog.DialogStateMachineFactory" );
dSysEntryClass = luajava.bindClass( "org.schema.game.common.data.player.dialog.DialogStateMachineFactoryEntry" );
hookClass = luajava.bindClass( "org.schema.game.common.data.player.dialog.DialogTextEntryHookLua" );
dSys = luajava.newInstance( "org.schema.game.common.data.player.dialog.DialogSystem", dialogObject );
print(dSys);
factory = dSys:getFactory(bindings);
hook = luajava.newInstance( "org.schema.game.common.data.player.dialog.DialogTextEntryHookLua", "hookFunc", {} );
entry = luajava.newInstance( "org.schema.game.common.data.player.dialog.TextEntry",
"Bonsoir, client.\n" ..
"Je m'apelle ".. dialogObject:getConverationParterName() ..".\n"..
"Ce sera quoi?"..
"\n"
, 2000 );
factory:setRootEntry(entry);
dSys:add(factory)
return dSys
--frame = luajava.newInstance( "org.schema.game.common.data.player.dialog.DialogSystem", "Texts" );
--frame:test()
end
"Bonsoir, client.\n" ..
"Je m'apelle ".. dialogObject:getConverationParterName() ..".\n"..
"Ce sera quoi?"..
"\n"
Write only between the " and the \n are return to line.