NPC Code:
function InitializeImageArrays()
{
this.imageCount = 3; // Change this accordingly
setarray this.imageShow, this.imageCount; // 1 = auto show, 0 = no auto show
setarray this.imageIndex, this.imageCount;
setarray this.imagePosX, this.imageCount;
setarray this.imagePosY, this.imageCount;
setarray this.imageStartX, this.imageCount;
setarray this.imageStaryY, this.imageCount;
setarray this.imageWidth, this.imageCount;
setarray this.imageHeight, this.imageCount;
setarray this.imageLayer, this.imageCount;
// The main image
this.imageShow[0] = 1;
this.imageIndex[0] = 1;
this.imagePosX[0] = 0;
this.imagePosY[0] = screenheight - 118;
this.imageStartX[0] = 0;
this.imageStartY[0] = 71;
this.imageWidth[0] = 487;
this.imageHeight[0] = 118;
this.imageLayer[0] = 5;
// The HP bar
this.imageShow[1] = 1;
this.imageIndex[1] = 2;
this.imagePosX[1] = 15;
this.imagePosY[1] = screenheight - 72;
this.imageStartX[1] = 10;
this.imageStartY[1] = 29;
this.imageWidth[1] = 5;
this.imageHeight[1] = 27;
this.imageLayer[1] = 4;
}
function ShowImages()
{
for ( i = 0; i != this.imageCount; i++ )
{
if (this.imageShow[i] == 1)
{
showimg this.imageIndex[i], gui1.gif, this.imagePosX[i], this.imagePosY[i];
changeimgpart this.imageIndex[i], this.imageStartX[i], this.imageStartY[i], this.imageWidth[i], this.imageHeight[i];
changeimgvis this.imageIndex[i], this.imageLayer[i];
}
}
}
Does anyone know why this wont work? Both of there function are called when the npc gets created. The InitializeImageArrays function is called first. Then the ShowImages function.
I I set the imageCount to 1 then it doesnt cause an error, but then that defeats the whole purpose of what I am trying to do.
If it is an error in my script I just can't see what it is. What I believe is it is an error with the showimg command placed in a 'for loop'. I am just not sure so if anyone who knows what the problem is would post an answer I would greatly appreciate it.