| 11-24-2003, 05:38 AM | #1 |
I here people talk about using the action trigger "for each integer A or B do multiple actions" but i never quite understand how it works. How do you use this and when would u wanna use this? |
| 11-24-2003, 06:29 AM | #2 |
The intiger A and intiger B represent counters in a for loop. If your not a programer that might not make sense to you but here is how it works and why you might want to use it. First the statement itself. For each intiger A 1 to 10 do actions I know thats not exact but thats the general idea. Intiger A is a varible "a place holder" for a number. The first time the loop runs Intiger A will be equal to 1. And the next time it will be equal to 2. Essentaly Intiger A (and B) is just a predefinded varible that you can use as a counter. This is use to go through a list of some type such as a varible array that you have set up, or maybe to count somthing, such as how many player are still playing. Here is an example. For each intiger A 1 to 15 do actions -->set array_Of_Units[intiger A] = "Foot Man" This For loop will fill the varible array, array_Of_Units which has a type of unit type. ' so. array_Of_Units[1] would have "Foot Man" stored in it. The intiger A saves me from having to type: -->set array_Of_Units[1]= "Foot Man" -->set array_Of_Units[2]= "Foot Man" -->set array_Of_Units[3]= "Foot Man" ... -->set array_Of_Units[15]= "Foot Man" Fiften times. I hope that helps you. Neo_Genesis |
| 11-24-2003, 07:35 AM | #3 |
Actually, that helped me :D Thanks lol I knew how to use an integer array (well, to an extent) but I didn't know I could set one up like you just described. |
| 11-24-2003, 07:52 AM | #4 |
hmm no i dont get it but you help that dude above lol. I use variable integer array. Like to make a random weather effect i use wether integer array (1-4) and the # = to some type of weather. That whole integer A, B throws me off cause I know its a variable but I cant change to anything it just says A. |
| 11-24-2003, 10:20 AM | #5 |
What is does for the trigger For each integer A 1 to 10 do actions Is make varible A equal to 1, do the actions, the add one to A, then repeat. once A is equal to 10, it does the actions and stops. |
| 11-24-2003, 10:25 AM | #6 |
Sometimes you need placing one loop inside other. If outer loop is "For loop integer A" then you should use "For loop integer B" as inner loop and "Integer B" as its counter or your trigger won't work. |
| 11-25-2003, 01:16 AM | #7 |
Maybe it would help you if I described what a "loop" is. A loop is a conditional (meaning that it runs until somthing is no longer true, like 0 = 1) set of code that excuets statements over and over and over. So say I wanted to print my name 12 times. I would make somthing like (in pydo code (fake code)) (1) Loop while varible < 12 (2) print "Neo_Genesis" (3) varible = varible + 1 (4) End loop The first line (1) is the start of the loop this says for the varible (which I named varible but in WarCraft would be your Intiger A (or B)) is less then 12 execute the statments below The second line just says print my name on the screen, in warcraft that would be done with: Game: Display (all players) text: "Neo_Genesis" The third line incruments, or increases my varible by 1. So the first time the loop runs varilbe is equal to 1, the next time it is 2 and so on. And lastly the end loop which starts the whole thing over again. Now this is a little bit longer the the warcraft version which is only two lines. Lets take a closer look at what they d. Example 1: For each Intiger A 1 to 12 do actions -->Game: Display (all players) text: "Neo Genesis" Example 2: For each Intiger A 1 to 12 do actions -->Game: Display (player number(player index[Intiger A])) text: "Neo Genesis" In example 1, Neo_Genesis is displayed 12 times to 12 player. In example 2, Neo_Genesis is displayed 1 time to 12 players. The first person that will see it is player 1, then player 2 and so on. Now as for making a random weather effect there is actualy another function you can use called random. Which is far easyer to understand. Its just Math: Random(1, 5). This will pick a random number that could be ether 1 or 2 or 3 or 4 or 5. I hope that helps you. Neo_Genesis |
