Not exactly, but you can you If Then Else or Switch statements to only execute specific actions under specific circumstances (such as active players).
Edit: I think I misunderstood. As in you wish to change the event based on a variable (check every 1.0 seconds if there are 6 players and check every 0.5 seconds if there are 3, etc...) You can turn other triggers off and on with actions to reach the desired effect.
You could create a Repeating Timer (with the Start Timer action) and set its duration to a variable. Make sure that your event is also "Timer Expires" than "Periodic/Every X time".
You can set that variable to whatever you want according to the number of active players when the game starts, and change it when one leaves (also make sure to use the Start Timer action again so that the timer uses the new number from the variable rather than the old one).
It is possible using Galaxy Script, but not GUI. In Galaxy Script you can create / destroy triggers on the fly, as well as give them new events.
As an example, what you are asking would be akin to the following code in Galaxy Script:
triggert=TriggerCreate("myTrigger");//myTrigger being the ID of the functionTriggerAddEventTimePeriodic(t,5.0,c_timeGame);
-
Edit:
By the way, Stealth Toast's way of doing it won't work, I believe. The event doesn't store a reference to the variable, merely the value in that variable at the time that you added it.
It's different from unit related events that way, where you can specify a unit variable and if the unit changes the event does too (those get converted to UnitRefFromUnit(unit u) in the background).
This doesn't answer the question specifically, however it will help your situation specifically:
Stealthtoast is on the right track; but there is an even more efficient way of doing it.
With periodics, it is (through my personal testing of a dense loop) 15% more efficient to use a "repeat forever" loop with a "wait" at the end of it. You could do this, and as stealth suggested, use a variable to set the time waited.
I do wish you could add events to triggers, as you were able to in wc3, and it was a very good function!
masterwraith is not 100% right, you can create your own native functions so all of these galaxy functions become available for gui (important if you set the obfuscating feature)
Any type of loop will always be better than a periodic trigger (especially when it come to customizing triggers). If you are unfamaliar with it, i highly recommmend you starting learning about custom definitions and loops; you will use them more than half the time if you ever get fully involved in triggers.
masterwraith is not 100% right, you can create your own native functions so all of these galaxy functions become available for gui (important if you set the obfuscating feature)
Of course?
Though, in my opinion, people should simply learn to code in Galaxy. It's a lot faster and easier to organize.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
In particular I would like to modify a periodic Timer Event based on the active Players, however I can't find a way to do so...
@Labingo: Go
Not exactly, but you can you If Then Else or Switch statements to only execute specific actions under specific circumstances (such as active players).
Edit: I think I misunderstood. As in you wish to change the event based on a variable (check every 1.0 seconds if there are 6 players and check every 0.5 seconds if there are 3, etc...) You can turn other triggers off and on with actions to reach the desired effect.
@PirateArcade | I make games | Ask me things on Discord
You could create a Repeating Timer (with the Start Timer action) and set its duration to a variable. Make sure that your event is also "Timer Expires" than "Periodic/Every X time".
You can set that variable to whatever you want according to the number of active players when the game starts, and change it when one leaves (also make sure to use the Start Timer action again so that the timer uses the new number from the variable rather than the old one).
Thank you very much for your answers. I wanted to avoid running unnecessary If's etc.
@StealthToast: Go's answer sounds like the efficient Solution I've been looking for.
@Labingo: Go
It is possible using Galaxy Script, but not GUI. In Galaxy Script you can create / destroy triggers on the fly, as well as give them new events.
As an example, what you are asking would be akin to the following code in Galaxy Script:
-
Edit: By the way, Stealth Toast's way of doing it won't work, I believe. The event doesn't store a reference to the variable, merely the value in that variable at the time that you added it.
It's different from unit related events that way, where you can specify a unit variable and if the unit changes the event does too (those get converted to UnitRefFromUnit(unit u) in the background).
This doesn't answer the question specifically, however it will help your situation specifically:
Stealthtoast is on the right track; but there is an even more efficient way of doing it.
With periodics, it is (through my personal testing of a dense loop) 15% more efficient to use a "repeat forever" loop with a "wait" at the end of it. You could do this, and as stealth suggested, use a variable to set the time waited.
I do wish you could add events to triggers, as you were able to in wc3, and it was a very good function!
Skype: [email protected] Current Project: Custom Hero Arena! US: battlenet:://starcraft/map/1/263274 EU: battlenet:://starcraft/map/2/186418
@MasterWrath: Go
masterwraith is not 100% right, you can create your own native functions so all of these galaxy functions become available for gui (important if you set the obfuscating feature)
Glorn is actually the only one on the right path.
Any type of loop will always be better than a periodic trigger (especially when it come to customizing triggers). If you are unfamaliar with it, i highly recommmend you starting learning about custom definitions and loops; you will use them more than half the time if you ever get fully involved in triggers.
Of course?
Though, in my opinion, people should simply learn to code in Galaxy. It's a lot faster and easier to organize.