Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   Assigning functions to GUI objects (https://forums.graalonline.com/forums/showthread.php?t=83957)

xXziroXx 01-31-2009 12:45 PM

Assigning functions to GUI objects
 
It would be nice if you could do things like this, without generating a "function not found" error.

PHP Code:

//#CLIENTSIDE
function onCreated()
{
  new 
GuiWindowCtrl("Debug") {
    
this.testFunc = function () {
      echo(
"Sup?");
    };
    
    
this.testFunc();
  }


NPC Code:
GraalScript: Function Debug.testFunc not found in script of Weapon Public/xXziroXx/Debug


cbk1994 01-31-2009 08:51 PM

I don't understand, why shouldn't it give an error?

xXziroXx 01-31-2009 08:53 PM

Quote:

Originally Posted by cbk1994 (Post 1461507)
I don't understand, why shouldn't it give an error?

What are you not understanding about it? x_x

http://forums.graalonline.com/forums...ad.php?t=74042

WhiteDragon 01-31-2009 09:49 PM

I'm not sure, but function prototypes may not automatically be declared public and it looks like the way it's calling it is "Debug.function()" when you use "this." making it required to be public...

Although that's all speculation.

xXziroXx 01-31-2009 10:02 PM

Quote:

Originally Posted by WhiteDragon (Post 1461524)
I'm not sure, but function prototypes may not automatically be declared public and it looks like the way it's calling it is "Debug.function()" when you use "this." making it required to be public...

Although that's all speculation.

Then it would say not accessible rather then not found, like it always does otherwise.

Inverness 01-31-2009 10:57 PM

Quote:

Originally Posted by xXziroXx (Post 1461528)
Then it would say not accessible rather then not found, like it always does otherwise.

Have you tried declaring an event and triggering it to test that theory?

cbk1994 01-31-2009 11:12 PM

Quote:

Originally Posted by xXziroXx (Post 1461509)
What are you not understanding about it? x_x

http://forums.graalonline.com/forums...ad.php?t=74042

Sorry, my fault. I didn't see that you were declaring a function in it. :blush:

xXziroXx 02-01-2009 12:48 AM

Interesting.

This does NOT work:
PHP Code:

//#CLIENTSIDE
function onCreated()
{
  new 
GuiWindowCtrl("Debug") {
    
this.testFunc = function () {
      echo(
"Sup?");
    };
    
    
this.testFunc();
  }


This works...
PHP Code:

//#CLIENTSIDE
function onCreated()
{
  new 
GuiWindowCtrl("Debug") {
    
this.testFunc = public function () {
      echo(
"Sup?");
    };
    
    
this.testFunc();
  }


... but still gives the error GraalScript: Function Debug.testFunc not found in script of Weapon Ziro/Debug

This works...
PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
this.testFunc = public function () {
    echo(
"Sup?");
  };
  
  
this.testFunc();


... but still gives the error GraalScript: Function testFunc not found in script of Weapon Ziro/Debug

This works...
PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
this.testFunc = function () {
    echo(
"Sup?");
  };
  
  
this.testFunc();


... without giving an error.

:noob:

xXziroXx 11-13-2009 06:50 PM

Final bump for today! ^_^

coreys 11-13-2009 09:46 PM

Well, I know that function pointers (funcPointer = this.funcName; ) must be used with public functions.
Perhaps the Gui Control declaration is, in practice, equivalent to this:
PHP Code:

MyControl = new GuiControl();
with (MyControl)
{
  
10;
  
10;


In which case, not being able to access a private member would make sense.


All times are GMT +2. The time now is 02:05 PM.

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