• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] What does the for each integer a etc etc thing

Status
Not open for further replies.
Level 17
Joined
Jun 2, 2009
Messages
1,141
First of all i know it is the shame for the someone like me but i started to think i have a very low iq

Can someone explain this like a tell to someone have small brain. Like an idiot.
Simple and understandable from any idiot in this world

For each (Integer A) from 1 to 10, do (Actions)

What does it do?

Try to explain imagine i am brainless imbecil.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
It loops the integer A variable from starting integer and exits when reached the ending integer.

You can have your own integer variable initialized value to 0 and use it in looping integers.

Its very useful lets say in this case:
You want to create 5 units at the same time and create a special effect each on their position
In this case you can use loops to save huge lines of script like this:
For each integervariablename from 1 to 5 , do Actions
Create 1 unit on point face any degrees
Create special effect at position of last created unit.
Destroy last created special effect

This code saves you from writing 5 repeated script like:

Create 1 unit on point
Create special effect at position of unit
Destroy created effect
^ repeat the lines 5 times

Edit: Can be explainable furthermore by Jass but you said you have low understanding so probably youll not understand it xD.

It also involves in array variables lets say in this case:
You want to set 25 array variable value to 0 at the same time

For each IntegerVariableName from 1 to 25, do Actions
Set MyArrayVariable[ IntegerVariableName ] = 0

^ this simple loops actually transform into:

Set MyArrayVariable[ 1 ] = 0
Set MyArrayVariable[ 2 ] = 0
Set MyArrayVariable[ 3 ] = 0
Until you reached the "Set MyArrayVariable[ 25 ] = 0 "

Its roughly slow to write this type without loops obviously.

Note that the IntegerVariableName value changes everytime in the loop based on the range parameter you have given: " from ( startingnumber to endingnumber ) " ex: from 1 to 10

Also note that using waits inside the loop are not recommended.
 
Last edited:
Status
Not open for further replies.
Top