array help

hey guys i’ve been working with a series of arrays to acheive certain stuff, regardless i was wondering if its possible to add to an array, thanks ill put a half peusudo script below :stuck_out_tongue:

var itemtest = Array(item1,item2,item3);

function update () {
if(Input.GetButtonDown(“1”)) {
add item4 to array;
}
}

I don’t usually write JavaScript but I believe there’s two ways to declare arrays and you would want this method:

var itemtest = new Array();
itemtest[0] = item1;
itemtest[1] = item2;
itemtest[2] = item3;

function update () { 
if(Input.GetButtonDown("1")) { 
itemtest[3] = item4;
} 
}

There is probably a quicker way of declaring the variables in the array than that but you get the idea.

thanks for the reply man, will give it a try :smile: