View Single Post
  #15  
Old 05-12-2008, 11:26 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by zokemon View Post
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;
    
10;
    
10;
    
this.itemName "Guns/KABOOM!!!111!!";
  }
}

function 
onItemSelected(obj) {
  for(
temp.i=0player.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.
__________________
Reply With Quote