Combining Trigger Conditions...

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
jkgarner
Posts: 175
Joined: Thu Apr 30, 2020 12:42 pm

Combining Trigger Conditions...

Post by jkgarner »

OK,

I'd like to create a single event that will check that a unit enters an area, but only check for unit entry during a certain time-frame... in other words: At some time Y in the future, the event starts checking and continues to check for the unit entering the area until either the unit enters the area, or the unit is destroyed before entering the area, or it times out after some time with the unit not entering in the area.

So far, I have managed to get the behavior that I want by setting up 2 events to accomplish this:
1 a time event that generates a recurring event at time Y, and kills itself..
2. the recurring event checks for the end time, and kills itself
the recurring event checks for the unit's entry into the area...
does something and kills itself.
the recurring event check to see if the unit has been killed. If so, it kills itself.


In looking at the help/documentation, I do not see a simpler way to do this.

I see trigger an event to fire at a time.
I see trigger an event to fire every interval.
But no way to combine them except through a lua script on the condition, but this means that the trigger fires every interval (polling) from inception until the event is removed.

Is there a way to get the behavior with a single event and or trigger and condition that minimizes the number of fires, meaning to do this where the trigger ONLY fires every interval during the desired time window?











User avatar
TitaniumTrout
Posts: 469
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

RE: Combining Trigger Conditions...

Post by TitaniumTrout »

Why not use the built in time selector? Then it will only fire between a certain time when that unit enters the area.

Image
jkgarner
Posts: 175
Joined: Thu Apr 30, 2020 12:42 pm

RE: Combining Trigger Conditions...

Post by jkgarner »

I need to do it through Lua.[:)]
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Combining Trigger Conditions...

Post by KnightHawk75 »

Is there a way to get the behavior with a single event and or trigger and condition that minimizes the number of fires, meaning to do this where the trigger ONLY fires every interval during the desired time window?

As I understand this you have what you want working, but you're asking is there a simpler way. No I don't think there is a simpler one for specifically what you want. I guess you could make it all-in-one and gate the meat of it actually doing anything using start\stop UTC timestamps every second for "simplicity", but that's ultimately more event "fires" than your current method, just for sake of removing #1, and not something I'd recommend.

Post Reply

Return to “Lua Legion”