Code help for event

All discussions & material related to Command's Lua interface

Moderators: michaelm75au, angster, RoryAndersonCDT, MOD_Command

Post Reply
rvseydlitz
Posts: 178
Joined: Wed May 09, 2012 12:52 pm

Code help for event

Post by rvseydlitz »

Good day.
I am attempting to schedule an event named "weapons free* that will run at a random time after another event named "war warning".
The mission editor does not seem to allow for "event A haa occured" to use the random time trigger.
I have not truly messed with Lua, but it seems that may be my solution.
Any help greatly appreciated!
Thank you
Durendal28
Posts: 9
Joined: Wed Apr 22, 2020 7:56 pm

Re: Code help for event

Post by Durendal28 »

Assuming you have two events named "War Warning" and "Weapons Free", create a Lua Action and add the following code to the action:

ScenEdit_SetEvent({'Weapons Free',{isActive = true})

Add the action you just created to the "War Warning" event.

Next, uncheck the Is Active box for the "Weapons Free" event.

When you run the simulation, the "War Warning" event will trigger and mark the "Weapons Free" event active. That event will then trigger at a random time.

I hope this helps.
rvseydlitz
Posts: 178
Joined: Wed May 09, 2012 12:52 pm

Re: Code help for event

Post by rvseydlitz »

One quick followup question.
Do I leave the second event (weapons free) as is with the random time, and that random time will not begin until it is activated by the Lua script?

Thank you!
Durendal28
Posts: 9
Joined: Wed Apr 22, 2020 7:56 pm

Re: Code help for event

Post by Durendal28 »

Yes, leave the ‘weapons free’ event as is with the random time trigger. Just make sure the event is not marked active.
rvseydlitz
Posts: 178
Joined: Wed May 09, 2012 12:52 pm

Re: Code help for event

Post by rvseydlitz »

So, I have still not gotten it to work.
The LUA console returns the following error, which I am certain, must be something small I am still doing incorrectly.

Lua version: Lua 5.4
>> ScenEdit_SetEvent({'Weapons Free',{isActive = true}
ERROR: [string "Console"]:1: '}' expected near <eof>
Parel803
Posts: 945
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

Re: Code help for event

Post by Parel803 »

Goodmorning,

Looking at: https://commandlua.github.io/assets/Fun ... Event.html
It might be the () and {} were they are in the example.

regards GJ
Post Reply

Return to “Lua Legion”