Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-09-2009, 11:38 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Object functions...

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
obj.testfunct();
}

function 
obj.testfunct() {
  
player.chat "hi";

This does not work, you can't trigger your own functions onto other objects. However, you can do this and it works just fine:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
obj.testfunc();
}

obj.testfunc = function() {
  
player.chat "hi";


So for further example:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  new 
GuiWindowControl("lalala") {
    
width height 50;
    
50;
    
profile GuiBlueWindowProfile;
  }
  
lalala.hi();
}

function 
lalala.hi() {
  
player.chat "hello";

This does not work. Neither does this:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  new 
GuiWindowControl("lalala") {
    
width height 50;
    
50;
    
profile GuiBlueWindowProfile;
    
thiso.catchEvent(this"hi""LALA123");
  }
  
lalala.hi();
}

function 
LALA123() {
  
player.chat "hello";

This doesn't work either:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  new 
GuiWindowControl("lalala") {
    
width height 50;
    
50;
    
profile GuiBlueWindowProfile;

    
this.hi = function() {
      
player.chat "hi";
    }
  }
  
lalala.hi();

However, this works fine:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  new 
GuiWindowControl("lalala") {
    
width height 50;
    
50;
    
profile GuiBlueWindowProfile;
  }

  
lalala.hi = function() {
    
player.chat "hello";
  }

  
lalala.hi();

However, none of these problems occur serverside. So... yeah.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #2  
Old 05-10-2009, 09:29 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
I've done some research on this topic before, and I have another quirky example of code:

PHP Code:
new GuiControl("toastControl") {
  
this.testFunc = public function() {
    echo(
"Hi there!");
  };
}

toastControl.testFunc(); 
The code works perfectly fine, but it throws a syntax error.
Reply With Quote
  #3  
Old 05-10-2009, 12:44 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Crow View Post
I've done some research on this topic before, and I have another quirky example of code:

PHP Code:
new GuiControl("toastControl") {
  
this.testFunc = public function() {
    echo(
"Hi there!");
  };
}

toastControl.testFunc(); 
The code works perfectly fine, but it throws a syntax error.
That's just odd o.o

It works when using public function, but not without public..

PHP Code:
new GuiControl("toastControl") {
  
thiso.toast this;
}
this.toast.testFunc = function() {
  echo(
"Hi there!");
};
this.toast.testFunc(); 
The above works, but the other 'object functions' issues should be fixed
__________________

Last edited by Chompy; 05-10-2009 at 01:00 PM..
Reply With Quote
  #4  
Old 05-10-2009, 04:33 PM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Can't you just join the object to a class?

Class guifunctions:
PHP Code:
//#CLIENTSIDE
function changetext(newtext) {
  
this.text temp.newtext;
  
player.chat "Changed text to " temp.newtext;

Weapon GUI:
PHP Code:
//#CLIENTSIDE
function onCreated() {
  new 
GuiButtonCtrl("MyButton") {
    
this.join("guifunctions");
    
this.profile GuiButtonProfile;
    
this.text "Some text";
  }
}
function 
MyButton.onAction() {
  
MyButton.changetext("Other text");

I haven't tested this specific one myself, but Inverness' GUI fading works this way; you join the window GUI to a class, and use MyWindow.fadein(), etc.

Though this is probably going to be considered a work-around, I find it more organized.
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #5  
Old 05-10-2009, 07:30 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by LoneAngelIbesu View Post
Can't you just join the object to a class?
Of course we can, but that's not the point of this thread.
__________________
Reply With Quote
  #6  
Old 05-10-2009, 07:48 PM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by Chompy View Post
Of course we can, but that's not the point of this thread.
Obviously, which is why I mentioned that joining a class is probably a work-around. Personally, I find using a class more organized.

PHP Code:
new GuiControl("toastControl") {
  
this.testFunc = public function() {
    echo(
"Hi there!");
  };

This just looks bad.
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #7  
Old 05-10-2009, 08:06 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
if graal had lua this never happen
Reply With Quote
  #8  
Old 05-10-2009, 08:24 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by LoneAngelIbesu View Post
Obviously, which is why I mentioned that joining a class is probably a work-around. Personally, I find using a class more organized.

PHP Code:
new GuiControl("toastControl") {
  
this.testFunc = public function() {
    echo(
"Hi there!");
  };

This just looks bad.
Pure preference.
Reply With Quote
  #9  
Old 05-10-2009, 08:28 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by LoneAngelIbesu View Post
Obviously, which is why I mentioned that joining a class is probably a work-around. Personally, I find using a class more organized.

PHP Code:
new GuiControl("toastControl") {
  
this.testFunc = public function() {
    echo(
"Hi there!");
  };

This just looks bad.
I don't really think it looks that bad and I would prefer it over creating an entire class just to invoke one small function.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
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 02:06 PM.


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