Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Dynamic GUI names (https://forums.graalonline.com/forums/showthread.php?t=80645)

Knight 07-20-2008 03:14 AM

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

cbk1994 07-20-2008 04:35 AM

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 "." );
  }



Rave_J 07-20-2008 06:12 AM

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.

Inverness 07-20-2008 06:29 AM

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);



The_Kez 07-20-2008 07:29 AM

Quote:

Originally Posted by Inverness (Post 1405665)
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.

zokemon 07-20-2008 07:35 AM

you want:
PHP Code:

thiso.catcheventthis.name "onAction""onButtonReceive" ); 

Inverness was getting confused with trigger().

Inverness 07-20-2008 07:39 AM

Quote:

Originally Posted by zokemon (Post 1405681)
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.

The_Kez 07-20-2008 07:42 AM

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 =)


All times are GMT +2. The time now is 06:44 PM.

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