Multiple triggers required for an event

Post new mods and scenarios here.

Moderator: MOD_Command

Post Reply
User avatar
AAaronson
Posts: 15
Joined: Fri Dec 06, 2024 8:20 pm

Multiple triggers required for an event

Post by AAaronson »

Heya Gang,

Here's the quick version: I have a scenario I'm working on where the Blue team doesn't know if the Red team has MANPADs. I would like to have an event that will withdraw all air assets after a second airframe is lost. I saw this thread:
https://forums.matrixgames.com/viewtopic.php?t=391832
however, it wasn't quite right. In my example, I don't have two specific aircraft that would be shot down, it's ANY aircraft. Is this something that can be done via lua? Maybe I just need to rethink this?

Any help would be appreciated.

-AAa
caelunshun
Posts: 95
Joined: Sun Nov 19, 2023 12:44 am

Re: Multiple triggers required for an event

Post by caelunshun »

You can use ScenEdit_SetKeyValue to keep track of how many aircraft have been lost. Make an event that is triggered whenever an aircraft for your side is destroyed. Add a Lua script action:

local destroyed_count = tonumber(ScenEdit_GetKeyValue("aircraft_lost")) or 0
destroyed_count = destroyed_count + 1
if destroyed_count == 2 then
-- withdraw aircraft, e.g. ScenEdit_SetMission(side_name, mission_name, { isactive = false })
end
ScenEdit_SetKeyValue("aircraft_lost", tostring(destroyed_count))
User avatar
AAaronson
Posts: 15
Joined: Fri Dec 06, 2024 8:20 pm

Re: Multiple triggers required for an event

Post by AAaronson »

Thank you for the quick reply! This'll be my first foray into lua, so, fingers crossed!

-AAa
Post Reply

Return to “Mods and Scenarios”