• 🏆 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!

[JASS] array initialization

Status
Not open for further replies.

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
Hi,

i have a problem,
i want to store temporarilty some unit into an array, and use the unit[x] inside the trigger.
i won't need it outside the trigger so i want to make it local.
local unit is ok but how to declare a local unit array?
unit[0]
unit[1]
etc...
will it work if i use a loop to fill the local unit[] with data?
because there is no way to specify the size of the array and initialize it...
i don't know in advance how many units i will store in it.
 

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
thanks i had problems because i tried to use
local unit array name[]
actually i didn't need the []
only need them later when store things...

but another problem after i don't need anymore the data how do i clean all the array data?
[Jass=]
local integer count
local unit array unitz

set count = count + 1
set unitz[count] = u (a unit variable)
do things with unitz

//cleaning
set i = 1
loop
exitwhen i > count
set unitz=null
set i = i +1
endloop
[/code]
is it ok like this?
 
Status
Not open for further replies.
Top