KnightHawk75
Posts: 1450
Joined: 11/15/2018 Status: offline
|
But trying to get a LuaScipt action to no avail. How is it written into the Seteventaction? -- So if you're trying to assign an existing LuaScript Action that you have created via gui to an event you are creating in a script and you already have the trigger created and stuff: ScenEdit_SetEvent(..sounds like you have this already)
ScenEdit_SetTrigger(..sounds like you have this already)
ScenEdit_SetEventTrigger(NameORGuidofTheEventYouCreatedAbove, {mode='add', name='NameOfTriggerYouCreatedAbove'})
ScenEdit_SetEventAction(NameORGuidofTheEventYouCreatedAbove, {mode='add', name='NameOfAlreadyMadeLuaScriptAction'})
How exactly is the Scriptext written into the Seteventaction? If you mean, you want to script the creation of the Lua Script action itself this would be how.
local bk = "\r\n"
local scriptText1 = 'local abc = 123; print("hello world! I'm now doing going to switch sides");' .. bk .. 'if(abc) == 123 then' .. bk .. 'print("abc=123 bla bla bla ");' .. bk .. 'else' ..bk .. 'print("abc not 123");' .. bk .. end'
ScenEdit_SetAction({mode='add', type='LuaScript', name= 'MyWonderfulAction', ScriptText = scriptText1})
^ creates the LuaScript action using the script you've provided.
--Then just like you use an existing one...
ScenEdit_SetEvent(..you have this already..)
ScenEdit_SetTrigger(..sounds like you have this already)
ScenEdit_SetEventTrigger(NameORGuidofTheEventYouCreatedAbove, {mode='add', name='NameOfTriggerYouCreatedAbove'})
ScenEdit_SetEventAction(NameORGuidofTheEventYouCreatedAbove, {mode='add', name='MyWonderfulAction'})
Not sure I see the need for the second method of scripting the script(but maybe there is a reason\detail of the scene I don't know). BTW you can have multiple actions to one event, so you could have the message first, and a luascript action second. Some related threads that deal with script events and scripting script creation. Namely timed events and triggers but it applies about the same. Found just by searching on SetAction, probably more. http://www.matrixgames.com/forums/fb.asp?m=4759748 http://www.matrixgames.com/forums/fb.asp?m=4559797 http://www.matrixgames.com/forums/fb.asp?m=4846163 http://www.matrixgames.com/forums/fb.asp?m=4390833 http://www.matrixgames.com/forums/fb.asp?m=4822622 If you're having specific problem with a piece of code, let me know.
|