Event Editor Lua Conditions
Posted: Thu Apr 14, 2016 3:53 am
I tried adding a condition to an event so that it would only fire after 2 units had been destroyed. The set-up was as follows:
Event 1
Trigger: Scen start +1s
Action (Lua Script): Counter=0
Event 2
Trigger: Side A Aircraft Lost
Action (Lua Script): Counter=Counter + 1
Event 3
Trigger: Side A Aircraft Lost
Condition (Lua Script): Counter == 2
Action (Special Message): It worked.
When I ran this and killed off one of the aircraft on Side A the game crashed. Pretty sure this is my fault, not a bug. I saw that Event 2 was triggered but not Event 3; I am not sure if I'm using the condition field properly.
I ran the Lua commands one by one through the script console and everything seemed to work fine; Counter == 2 returned 'No' when it was 0 and 1, and 'Yes' when it was 2. No crashes.
I think I need to alter the Lua command for the condition but I'm not sure what to do. Can anyone point me in the right direction with this?
Event 1
Trigger: Scen start +1s
Action (Lua Script): Counter=0
Event 2
Trigger: Side A Aircraft Lost
Action (Lua Script): Counter=Counter + 1
Event 3
Trigger: Side A Aircraft Lost
Condition (Lua Script): Counter == 2
Action (Special Message): It worked.
When I ran this and killed off one of the aircraft on Side A the game crashed. Pretty sure this is my fault, not a bug. I saw that Event 2 was triggered but not Event 3; I am not sure if I'm using the condition field properly.
I ran the Lua commands one by one through the script console and everything seemed to work fine; Counter == 2 returned 'No' when it was 0 and 1, and 'Yes' when it was 2. No crashes.
I think I need to alter the Lua command for the condition but I'm not sure what to do. Can anyone point me in the right direction with this?