Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-11-2012, 10:37 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
catchevent parameters?

So I am trying to pass a variable with an event.. Not sure if it's possible? Or if I am way wrong on how to do it? I am planning to have let's say 10 images, and clicking on them will make the player chat the number of the image it clicked on..

PHP Code:
//#CLIENTSIDE
function onCreated() {
  for ( 
010i++ ) {
    new 
GuiShowImgCtrl("test" i) {
      
55;
      
50 40;
      
image "block.png";
      
thiso.catchevent(this"onMouseDown""onSelect"i); 
    }
  }
}
function 
onSelect() {
  
player.chat "a" SPC params[0];

Didn't work.

Removing i from catchevent(), however, shows the name of the Control.
Reply With Quote
  #2  
Old 02-11-2012, 11:21 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by scriptless View Post
So I am trying to pass a variable with an event.. Not sure if it's possible? Or if I am way wrong on how to do it? I am planning to have let's say 10 images, and clicking on them will make the player chat the number of the image it clicked on..

PHP Code:
//#CLIENTSIDE
function onCreated() {
  for ( 
010i++ ) {
    new 
GuiShowImgCtrl("test" i) {
      
55;
      
50 40;
      
image "block.png";
      
thiso.catchevent(this"onMouseDown""onSelect"i); 
    }
  }
}
function 
onSelect() {
  
player.chat "a" SPC params[0];

Didn't work.

Removing i from catchevent(), however, shows the name of the Control.
The parameter received is actually the GUI object rather than its name. You can just write this. variables to the GUI object itself then use the object as reference:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  for ( 
010i++ ) {
    new 
GuiShowImgCtrl("test" i) {
      
55;
      
50 40;
      
image "block.png";
      
this.num i;
      
thiso.catchevent(this"onMouseDown""onSelect"i); 
    }
  }
}
function 
onSelect(temp.gui) {
  
player.chat temp.gui.num;

Reply With Quote
  #3  
Old 02-11-2012, 07:39 PM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
There is no fourth parameter for catchevent.
__________________
Reply With Quote
  #4  
Old 02-11-2012, 08:08 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Do as ffcmike said. You cannot pass additional parameters to catchevent(). The first parameter in the catching function is always the object itself, and then follow the normal event parameters.
Remember additional values as this.variables in the GUI object itself.
Reply With Quote
  #5  
Old 02-11-2012, 08:31 PM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Quote:
Originally Posted by Stefan View Post
Do as ffcmike said. You cannot pass additional parameters to catchevent(). The first parameter in the catching function is always the object itself, and then follow the normal event parameters.
Remember additional values as this.variables in the GUI object itself.
Thanks, that clear's things up for me
Reply With Quote
  #6  
Old 02-19-2013, 04:29 AM
devilsknite1 devilsknite1 is offline
C:
devilsknite1's Avatar
Join Date: Jul 2006
Location: Florida, USA
Posts: 269
devilsknite1 has a spectacular aura about
Send a message via AIM to devilsknite1 Send a message via MSN to devilsknite1 Send a message via Yahoo to devilsknite1
Sorry for bumping this (it has been a year ), but I've been attempting this method to no avail.
I've attempted even Thor's simple example; any other ways to do this? Or am I just doing something incorrectly?

EDIT: FIXED! Thanks to Hoyt1134
In case anyone else has this problem, here's a possible solution based off of ffcmike's example. I instead wanted to send the image of the selected weapon, so I will replace it with what I wanted to do with it:
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
this.images = {};
  for ( 
temp.0temp.player.weapons.size(); temp.++ ) {
    
thiso.images.addplayer.weaponstemp.].image );
    new 
GuiShowImgCtrl"test" temp.) {
      
55;
      
50 temp.40;
      
image player.weaponstemp.].image;
      
thiso.catchEventthis.name"onMouseDown""onSelect" );
    }
  }
}
function 
onSelecttemp.gui ) {
  
temp.gui temp.gui.substring);
  
temp.image this.imagestemp.gui ];
  
player.chat temp.image;

Again, sorry for the bump, but this may be useful for others as catchEvent() does not include parameters... Maybe a useful addition?

Last edited by devilsknite1; 02-19-2013 at 05:21 AM..
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:46 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.