Page 1 of 1

Code help for event

Posted: Wed Sep 06, 2023 3:13 pm
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

Re: Code help for event

Posted: Thu Sep 07, 2023 7:14 am
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.

Re: Code help for event

Posted: Thu Sep 07, 2023 3:30 pm
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!

Re: Code help for event

Posted: Thu Sep 07, 2023 5:30 pm
by Durendal28
Yes, leave the ‘weapons free’ event as is with the random time trigger. Just make sure the event is not marked active.

Re: Code help for event

Posted: Sat Sep 09, 2023 5:03 am
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>

Re: Code help for event

Posted: Sat Sep 09, 2023 7:40 am
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