Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

LUA events script.

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> LUA events script. Page: [1]
Login
Message << Older Topic   Newer Topic >>
LUA events script. - 10/4/2020 9:52:32 PM   
KLAB


Posts: 355
Joined: 2/27/2007
Status: offline
I've scoured forum for an example to no avail.
With LUA from a special action key I have:
Set and Event.
Set a trigger. (unit remains in area)
This fires an action which throws up a message. So far so good.
But trying to get a LuaScipt action to no avail. How is it written into the Seteventaction?
How exactly is the Scriptext written into the Seteventaction?
I'm trying to get one special action to add an aircraft which flies to a destination stays on the ground there for 1hr then changes sides from Neutral to Player.
I can get this to happen in LUA in isolation but not a one sequential event?
Any help much appreciated and in the context of even the beginners LUA examples being quite challenging.
Thanks.
K
Post #: 1
RE: LUA events script. - 10/4/2020 11:39:03 PM   
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.





(in reply to KLAB)
Post #: 2
RE: LUA events script. - 10/5/2020 6:25:17 AM   
KLAB


Posts: 355
Joined: 2/27/2007
Status: offline
Very much appreciated, it was an example such as this below I wanted, I just wasn't getting the syntax correct. Thanks again. ScenEdit_SetAction({mode='add', type='LuaScript', name= 'triggerunitAction', ScriptText ="ScenEdit_SetEMCON('Group', 'VisbyGroup', 'Inherit;Radar=Active')"}) -- Add an action that changes the EMCON back to active.

(in reply to KnightHawk75)
Post #: 3
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> LUA events script. Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

1.172