Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-20-2008, 03:14 AM
Knight Knight is offline
Banned
Join Date: Sep 2007
Location: United States
Posts: 230
Knight will become famous soon enough
Send a message via MSN to Knight
Dynamic GUI names

When you create a GUI that has a dynamic name, i.e "Test_Window1_"@acct how can you call the GUI objects back as objects? For example, if you create a GuiMLTextCtrl named "MultiLine1_"@acct how can you call back the text contained in the object? Calling "MultiLine1_"@acct.text doesn't work, or at least hasn't for me, so I figure that's incorrect syntax. I've also tried calling (MultiLine1_@""@acct).text, or similar, which also appears to be incorrect syntax.

Does anyone know how this can be done?
Also a second question, when a GUI is created is it indexed in any way so that I can tell which object to call back? Because if I have multiple dynamic GUIs, it might be difficult to find which GUI to call the information for without some sort of index or similar feature to find the name of the currently selected GUI.

Thanks for the help =)

- Knight
Reply With Quote
  #2  
Old 07-20-2008, 04:35 AM
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
If you create a dynamic GUI, you can use this:

PHP Code:
new GuiWindowCtrl"Test_" player.account "_Window" )
{
  
// blah
}

( @ 
"Test_" player.account "_Window" ).width 200// for example 
You can always use controls. Here's something I use sometimes:

PHP Code:
new GuiWindowCtrl"blah" )
{
  
this.isWhateverWindow true;
}

for ( 
control GraalControl.controls )
{
  if ( 
control.isWhateverWindow )
  {
    echo( 
"I found a window! It is" SPC control.name "." );
  }

__________________
Reply With Quote
  #3  
Old 07-20-2008, 06:12 AM
Rave_J Rave_J is offline
Graal Developer
Join Date: Feb 2006
Location: Texas
Posts: 848
Rave_J can only hope to improve
Send a message via AIM to Rave_J Send a message via MSN to Rave_J Send a message via Yahoo to Rave_J
How can you check for dynamic GUI events? I've been trying to do this for awhile but there's always some sort of syntax error. For example if you have a dynamic button you can't say
function ( "Test_" @ acct ).onAction() {
Because that returns a syntax error.
Reply With Quote
  #4  
Old 07-20-2008, 06:29 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
That's what catchevent() is for.

objectA.catchevent(objectBName, eventNameToCatch, newEventName);
PHP Code:
function blah() {
  new 
GuiButtonCtrl("SpecialButton" number) {
    
//stuff
    
thiso.catchevent(this.name"Action""ButtonAction");
  }
}
function 
onButtonAction(objectname) {
  echo(
"Button Action from " objectname);

The new event will always have the name of the object you're catching from as the first parameter.

The following script does the exact same as the above.
PHP Code:
function blah() {
  new 
GuiButtonCtrl("SpecialButton" number) {
    
//stuff
  
}
  
this.catchevent("SpecialButton" number"Action""ButtonAction");
}
function 
onButtonAction(objectname) {
  echo(
"Button Action from " objectname);

__________________
Reply With Quote
  #5  
Old 07-20-2008, 07:29 AM
The_Kez The_Kez is offline
N-Pulse Asst. Manager
The_Kez's Avatar
Join Date: Dec 2007
Posts: 106
The_Kez is on a distinguished road
Send a message via MSN to The_Kez
Unhappy

Quote:
Originally Posted by Inverness View Post
That's what catchevent() is for.

objectA.catchevent(objectBName, eventNameToCatch, newEventName);
PHP Code:
function blah() {
  new 
GuiButtonCtrl("SpecialButton" number) {
    
//stuff
    
thiso.catchevent(this.name"Action""ButtonAction");
  }
}
function 
onButtonAction(objectname) {
  echo(
"Button Action from " objectname);

The new event will always have the name of the object you're catching from as the first parameter.
I've also been curious about this for awhile. I understand the concept of how this would work, but when I create a test script to see if it actually works out it doesn't seem to produce anything. Right now I have:

PHP Code:
function newFuncindx ) {
  new 
GuiButtonCtrl"TestButton_" indx ) {
      
profile GuiBlueButtonProfile;
      
height 22;
      
width 67;
      
text "Test Button!";
      
50;
      
50;
      
thiso.catcheventthis.name "Action""ButtonReceive" );
  }
}
function 
onButtonReceiveobjectname ) {
  
player.chat objectname " has triggered this event!";

The ButtonReceive event isn't triggered at all. With 'objectname' am I supposed to just be parsing parameters like that or do I actually need to place a specific object name in there? Otherwise I'm not sure what I'm doing wrong.
Reply With Quote
  #6  
Old 07-20-2008, 07:35 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
you want:
PHP Code:
thiso.catcheventthis.name "onAction""onButtonReceive" ); 
Inverness was getting confused with trigger().
__________________
Do it with a DON!
Reply With Quote
  #7  
Old 07-20-2008, 07:39 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by zokemon View Post
Inverness was getting confused with trigger().
Actually, no I wasn't, thanks.

I asked Stefan why you needed "on" in the catchevent parameters and he said you don't and that it was cutting it off if it was there.
__________________
Reply With Quote
  #8  
Old 07-20-2008, 07:42 AM
The_Kez The_Kez is offline
N-Pulse Asst. Manager
The_Kez's Avatar
Join Date: Dec 2007
Posts: 106
The_Kez is on a distinguished road
Send a message via MSN to The_Kez
Well, I added the 'on' and it works perfectly now. So, if Stefan said that you don't need on and that it was cutting it off if it was there...he maybe needs to rework that? Because it needs on for it to function properly, at least I can't get it to work without it there.

Anyways thanks for the help =)
Reply With Quote
Reply


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 10:31 PM.


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