Quote:
|
Originally Posted by xXziroXx
Is there another way to make it check if an icon is pressed rather then doing like this for each slot:
|
Yes. You can use 'catchevent'. - catchevent(obj, oldevent, newevent);
PHP Code:
new GuiBitmapButtonCtrl( "InventoryButton" @ i) {
x = 16 + (32 + 8)*i, y = 16;
width = 32, height = 32;
mouseoverbitmap = tokens[1];
normalbitmap = tokens[1];
pressedbitmap = tokens[1];
//added this line:
thiso.catchevent(this, "onAction", "onButtonPressed");
}
Now, every time a button is pressed, 'onButtonPressed' will be called (with a parameter that is a reference to the object that called it).
Example:
PHP Code:
function onButtonPressed(obj) {
player.chat = temp.obj.name;
}