• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Event/Condition with Variables

Status
Not open for further replies.
Level 16
Joined
Oct 12, 2008
Messages
1,570
Hello people,,

As always, i go straight to the point,,

When i register a player event, and i use a variable in it,
like this:
call TriggerRegisterPlayerUnitEvent(t, udg_Player, EVENT_PLAYER_UNIT_DEATH, null)

will it run only for the preset player? (The player that is initialized as that variable), or will it run for what player is in the variable at that moment?

Lets say on initialization, udg_Player is Player(0), red,,
It runs for Player Red then,
When time is 5 seconds, i change the variable to Player(1), blue,,
Will the trigger now run for Player Red, or Player Blue??

I actually have the same question for a condition, but after thinking for a while i found out that it does (i used it in GUI some times),,
(or does it?)

Thanks in Advance! =)

-Yixx,,-
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,217
Events get passed the value of the variable, as they are natives and they use that value until the trigger is destroyed.

Conditions however are run as function statments everytime something executes them, thus they use the value of the variable at that time of execution.

Inorder for a dynamic event, you need to update a system every time you change the value so that it destroys the current trigger and creates a new one with the new event and same actions / conditions. This however has its own problems as destroying triggers can have wierd and unstable effects.
 
Status
Not open for further replies.
Top