| 06-24-2005, 07:33 AM | #1 |
Ok this might sound like a dumb question, but i really can't understand the whole "For each integer A do (actions)" and "For each integer A through B do actions" thing. I've looked at people's explainations of it and I still can't get my head around it. Can someone please give me a really simple, easy to understand explaination of it because I hear it's very useful. Thanks in advance! |
| 06-24-2005, 07:46 AM | #2 |
Well when you make a "For each integer A" action It makes a little window that says something like "For each Integer A 1 through 10" You change the numbers for whatever thing you are doing. For example. Lets say we are making a trigger to make a unit pop out for each charged item a hero is holding. You do "Each integer A 1 through 6 (because there are 6 inventory slots) Code:
For each (Integer A) 1 to 6, do (Actions)
Loop Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Condition
(Item-class of (Item carried by Archmage001 in slot(IntegerA))) Equal to Charged
Then - Actions
Unit - Create 1 Footman for Player1(Red) at (Center of(Playable map area)) facing Default building degreesThat way, you can do that one trigger using "IntegerA" as a number instead of making a seperate function for slots 1-6 This is just a function that can be done with that that I thought of off the top of my head, there are far more things that can be done with this. Like doing events for players using IntegerA 1-(however many players) or something. |
| 06-24-2005, 11:01 AM | #3 |
Basically it loops from integer A to B. Eg, if integer A = 3, B = 5 it would loop the actions attached to it 3 times, 3,4,5. For each integer A, and the other one integer B is there because integer A function cant be run at the same time. |
| 06-24-2005, 01:13 PM | #4 |
it's a counting trigger. It creates a "loop" for however many times you want. if a = 5 it would loop 5 times. Helps a lot if you want to make 5 units. You could do make unit1 make unit2 make unit3 make unit4 make unit5 but using "for each integer a from 1 to 5" makes this really easy :D you do for each integer a from 1 to 5 loop make unit would make 5 units. However, can you see how the first trigger is dealing with specific units and the 2nd trigger is dealing with numbers? THIS is why it's so good. You use arrays (AN ARRAY IS NOTHING MORE THAN A BUNCH OF VARIABLES IN A LOGICAL NUMBERING SYSTEM) let's make an array of "X" and we'll make the array 5 big (you do this when you make the variable I'll assume you know how to make a variable :D) so now we have X[1], X[2], X[3], X[4], and X[5]. These are all different variables. X[1] is not equal to X[2] etc... However, we now have a numbering system from which we can refer too, example: set X[1] to footman set X[2] to ghoul set X[3] to archer set X[4] to rifleman set X[5] to fiend now you do your "integer a from 1 to 5" loop and you say for each integer a from 1 to 5 loop create X[integer a] What units will this last trigger make? |
