• 🏆 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!

[Trigger] What's the difference between these?

Status
Not open for further replies.
Level 26
Joined
Aug 18, 2009
Messages
4,097
Integer A/B are globals. If you have a Wait action inside the loop, another trigger might fire meanwhile and change the value of A/B or the ending values of your iteration are stored inside globals, too. Even without Waits you could have actions in the loop body that potentially trigger events immediately. If your code has to be recursion-safe, even a dedicated global variable won't be enough. In Jass, you have the possibility to declare local variables, which are instanced everytime you run the function they belong to, so each call of the function is sovereign.
 
Status
Not open for further replies.
Top