Legacy GM [SOLVED] Is it possible to have temporary arrays?

O

Olivebates

Guest
When I try to instantiate an array like this:
Code:
var array[0,0];
It gives me an error.

Is there a way to have an array that gets deleted after I'm done using it?
 
A

Aura

Guest
Code:
var array;
array[0, 0] = 1;
In GameMaker, you can't declare arrays directly using the var declaration. You would have to declare it as a local variable (using var declaration) first, then use it as an array in the next statement.
 
G

Gre_Lor12

Guest
Code:
var array;
array[0, 0] = 1;
In GameMaker, you can't declare arrays directly using the var declaration. You would have to declare it as a local variable (using var declaration) first, then use it as an array in the next statement.
What Aura said above is true. It will not really "delete" itself like you want, but will rather just stay there until it isn't needed (Aka. if the object does not exist anymore etc)
 
A

Aura

Guest
Pffft, I didn't read the entire post, so I missed that part about deleting arrays. ^^"

Using local variables would make your array local to that code action, so you won't be able to use it anywhere else.

http://docs.yoyogames.com/source/da...guage overview/variables/local variables.html

If you want to use the array only in that code action then you can use var declaration. If that is not the case, setting the identifier to a value (as a variable) should be a viable option.

Code:
array = 0;
 

ZeDuval

Member
Also, script:
Code:
/// array(value1,value2,value3,...)
var a,i=argument_count;
repeat i{ a[--i] = argument[i]; }
return a;
Usage:
Code:
var arr = array("A",5,obj_dude);
I'm sorry if there is a mistake, I'm not at home and can't control it right now. If so I'm sure one of the other awesome guys can jump in! ;)
 
Top