good definition of arrays, read it, and i am sure u'll undertstand.
NPC Code:
// to make an array do this:
// setarray arrayname,size;
// as in this example:
setarray this.values,10;
/*
to set values in an array do this:
arrayname[indexnumber] = value;
the first index in every array is 0.
so if you have an array that you set to size 100
than its 0-99.
as in this example:
*/
this.values[0] = 1;
this.values[9] = 5;
/*
that is the hard way to do it though,
this is easier:
*/
this.values = {1,0,0,0,1,2,3};
/*
that will set an array with 7 values (0-6)
and can be called as so:
*/
this.newnumber = this.values[5];
/*
Meaning that this.newnumber would equal 2
*/
Mostly with big arrays you put them thru a for loop,
like in this rain example:
*/
// Rain script:
if (created) {
setarray this.rainx,100;
setarray this.rainy,100;
for (i=0;i<arraylen(this.rainx);i++;) {
/* arraylen(arrayname) <-- gives you the amount of indexes in the array.*/
this.rainx[i] = random(0,64);
this.rainy[i] = random(0,64);
}
}
if (playerenters||timeout) {
for (i=0;i<arraylen(this.rainx);i++;) {
// Shows rain:
showimg i+500,@.,this.rainx[i],this.rainy;
// Puts the rain above the player:
changeimgvis i+500,3;
// If the rain reaches the end of the screen it will repeat:
this.rainx[i]+=(this.rainx[i]>64 ? -64 : 0);
this.rainy[i]+=(this.rainy[i]>64 ? -64 : 0);
/*
if this:
this.rainx[i]+=(this.rainx[i]>64 ? -64 : 0);
looks weird, what it is, is a condition, if you look, the syntax is this:
(condition ? a : b)
if the condition is true than it goes to a otherwise it goes to b.
If it doesn't make sence im me we can talk about it.
*/
}
timeout=.05;
}