# [Trigger]Variables using array

Status
Not open for further replies.

#### Dracula

Level 9
how do i make a variables that keeps making array for it self?
for ex.

do integer 1-50
-create dummy unit for player 1
-set temp unit[0 + 1] = last created unit

now the thing is i want the variable to do +1 +2 +3, so it would store all created units but i cant seem to get it to work.

#### GhostWolf

Level 29
Well, you can declare a Ineger and raise its value by 1 each time you create a unit, like this

• Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
• Set Unit[Integer] = (Last created unit)
• Set Integer = (Integer + 1)

However, in my opinion, the best way to do this is using a loop like this (in case you are creating them one after another)

• For each (Integer A) from 1 to 50, do (Actions)
• Loop - Actions
• Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
• Set Unit[(Integer A)] = (Last created unit)

When the loop runs its "1" (first time it runs), it will set your unit to Unit[1], when it runs its "2" it will set it to Unit[2] and so on untill 50.

#### Dracula

Level 9
ohh thanks this is exactly what i want.

btw could loop go over 50?

#### GhostWolf

Level 29
I don't think it has any limit.

Uh, actualy on a second thought, the loop numbers is a Integer so the max woud be I think something around 2,2XX,XXX. Or was it 2,2XX,XXX,XXX ?

#### aznricepuff

Level 11
There is a limit: its 8192. But you most likely will never reach it.

#### Eleandor

Level 21
It could however be that without waits, the OP limit will be reached after, perhaps looping 4 000 times. Then again, I don't want to know what you need a 4K loop for...

#### Need_O2

Level 19
Tip: Put a Custom script: call DestroyGroup(bj_lastCreatedGroup)

CreateNUnitsAtLoc (Unit - Create ...) Creates an Unit Group and its bj_lastCreatedGroup
(bj_wantDestroyGroup doesnt work because it doesnt check that variable nor contains anything to destroy that group)

Status
Not open for further replies.

Replies
4
Views
963
[Trigger] Variable Array
Replies
8
Views
2K
[Trigger] Array Size
Replies
44
Views
4K
Replies
10
Views
823
Replies
2
Views
547