Quote:
Originally Posted by zokemon
Another way to do that would be like:
PHP Code:
function onCreated() {
catchevent(InvItem_0, "onMouseDown", "onItemSelected");
new GuiShowImgCtrl( "InvItem_0" ) {
image = "x.png";
width = 32;
height = 32;
x = 10;
y = 10;
this.itemName = "Guns/KABOOM!!!111!!";
}
}
function onItemSelected(obj) {
for(temp.i=0; i < player.weapons.size(); ++i) {
if (player.weapons[i].name == obj.itemName) {
player.selectedweapon = i;
break;
}
}
}
Basically, catchevent can be called outside of the object (the object that actually gets the "catchevent" call is most likely going to be the WNPC that you are in which is why Chris used thiso.), the first parameter is the object that you are catching and it can be called before the object is even created  .
|
I didn't know you could do that, thanks for the tip

I never used catchevent much except for tabs (easy to detect which tab without many functions since they more or less do the same thing) and where there are dynamic buttons.