HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

For Loop Integer A

10-07-2003, 02:31 AM#1
saus
What can/does 'For Loop Integer A' do? An example would be nice.
10-07-2003, 02:34 AM#2
FyreDaug
It's a loop, it will loop integer A, which is just a local variable (only used in that trigger, so other integer A's outside that trigger won't be affected)


set number = 0
For Loop Integer A 1 to 10
set number = number + 1

That will set number equal to 0, then it will loop adding 1 to the number 10 times. The result would be 10.
10-07-2003, 02:45 AM#3
Grater
A more pratical example and the sort of thing I use "for loop integer A" for, say you want to create 10 units in a region and make them "dance"
Code:
Dancing footmen
    Events
        Time - Elapsed game time is 5.00 seconds
    Conditions
    Actions
        For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                Unit - Create 1 Footman for Player 1 (Red) at (Random point in Dance Floor <gen>) facing Default building facing degrees
                Unit - Order (Last created unit) to Patrol To (Random point in Dance Floor <gen>)

There are lots of uses for For Loop Integer, some others include iterating over arrays and doing something to each player with a player number between 1 and 10. (for example)
10-07-2003, 03:02 AM#4
Zachary_Shadow
Just what I needed ! Thanks alot :))