Staredit Network > Forums > SC2 General Discussion > Topic: [Info] "For each" Undocumented Change 2.0.10
[Info] "For each" Undocumented Change 2.0.10
Aug 8 2013, 2:49 am
By: Ahli  

Aug 8 2013, 2:49 am Ahli Post #1

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

"For each integer/real" works differently after 2.0.10.

After finishing the loop, the variable won't end with the end value that you set in that function anymore (or the last correct value it had before).

For example, the following code ends with A being set to 10.0 after the loop:
Code
General - For each real A from 0.0 to 9.0 with increment 1.0, do (Actions)


Due to the way sc2 translates GUI to mapscript's galaxy code, maps can only be bugged when you update them. So, if you've updated your map or plan to update it, you might be adding bugs to it without being aware of that.

So, please check your maps for possible side effects. Note that this can only be a problem when you re-use the current value of the loop's variable.




Aug 8 2013, 8:33 am TF- Post #2

🤙🏾

Shouldn't this be getting fixed?

Probably not worth a thread but a thing I noticed is if you're changing a unit's max energy, its current energy gets set to the max energy now. Made for a small bug in my mod.



🤙🏾

Aug 8 2013, 9:46 am Lanthanide Post #3



It's a bit crap of Blizzard to change behaviour of a functional item like that, but I'd also suggest that if you were using "foreach", you shouldn't have been expecting variable A to have any particular value at the end of the loop.

Foreach has a distinctly different semantic meaning compared to a for loop which explicitly increments the counting variable and uses a test against that variable in order to exit the loop. Foreach literally just means "do this thing on all of the items in this loop", theoretically your use-case shouldn't care in what order the action is performed, just as long as it is performed exactly once for each item - the resulting value of the variable used to control the loop therefore shouldn't be assumed (unless the API indicates the value to expect). A for loop on the other hand is much less structured, and since it is simply checking against a variable value to decide when to exit the loop, the variable can be manipulated in numerous different ways within the body of the loop to give different exit behaviours, as well as for loops often being explicitly used to determine the appropriate value of the variable for further use (eg, count the number of characters in a string).



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[10:41 am]
v9bettel -- Nice
[01:39 am]
Ultraviolet -- no u elky skeleton guy, I'll use em better
[10:50 pm]
Vrael -- Ultraviolet
Ultraviolet shouted: How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
hey cut it out I'm getting all the minerals
[10:11 pm]
Ultraviolet -- :P
[10:11 pm]
Ultraviolet -- How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
[2024-4-17. : 11:50 pm]
O)FaRTy1billion[MM] -- nice, now i have more than enough
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- if i don't gamble them away first
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- o, due to a donation i now have enough minerals to send you minerals
[2024-4-17. : 3:26 am]
O)FaRTy1billion[MM] -- i have to ask for minerals first tho cuz i don't have enough to send
[2024-4-17. : 1:53 am]
Vrael -- bet u'll ask for my minerals first and then just send me some lousy vespene gas instead
Please log in to shout.


Members Online: Roy, jun3hong