Hey there!
findimg() basically returns the object of an image displayed at the given index, and there's really no limit to indices, besides the fact that from 0 to 200 will draw images relative to the level (0-64 x and y grid) and above will draw on a screen level (0 to screenwidth and screenheight)
You can also create images using findimg(#), as it will simply return an image object even though you have not created that said image beforehand.
PHP Code:
with(findimg(200)) {
image = "block.png";
width = height = 42;
x = screenheight/2 - width/2;
y = screenheight/2 - height/2;
}
When you assign variables inside the with() statement, there's no need to prepend variables with
this. as all the variables are in scope with the object you give
with()
You can also use it for referencing,
PHP Code:
// say you have a health bar on your GUI and you want to update it
function onCreated() {
// create gui, health bar is index 202 for example, assign it a maxwidth on creation
// for easier updating later on, or you can use the imagewidth function
this.healthbar = findimg(202);
}
function updateHealthBar() {
temp.php = max(player.health/player.maxhealth, 1); // player health percentage
// does not take into account bonuses like extra health or whatever you have in your system
// this is just an example
this.healthbar.width = temp.php > 0 ? (temp.php * this.healthbar.maxwidth) : 0;
}
And if my memory isn't wrong, showimg() will also return the image object, so you can do something like
NPC Code:
this.healthbar = showimg(200, "healthbar.png", 0, 0, 64, 16);
I didn't have a place to test this on, but if there's something more, just ask