Graal Forums  

Go Back   Graal Forums > Graal V6 forums > Announcements
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #16  
Old 05-19-2007, 11:11 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Stefan View Post
You can also do this, but keep care to add a semicolon behind the function declaration:

PHP Code:
this.func = function() {
  echo(
"nameless function");
}; 
Function prototypes! One of the best additions yet by far.

Wondering if it would be possible to have this.foo = public function () also, or something similar. Defining functions using this method in a TStaticVar results in a function inaccessible error in RC. Currently it is a bit of a pain to have to define a public function and copy it, if the functions you are defining are different for each object.
__________________
Skyld

Last edited by Skyld; 05-19-2007 at 03:33 PM..
Reply With Quote
  #17  
Old 05-20-2007, 12:13 AM
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
Quote:
Originally Posted by Twinny View Post
Aww...printf() in loops problem wasn't fixed .
Yes sorry, just checked again and found the problem, so it will be fixed with the next update.

Quote:
Originally Posted by Skyld View Post
Function prototypes! One of the best additions yet by far.
Wondering if it would be possible to have this.foo = public function () also, or something similar. Defining functions using this method in a TStaticVar results in a function inaccessible error in RC. Currently it is a bit of a pain to have to define a public function and copy it, if the functions you are defining are different for each object.
May be they should be public by default?
Reply With Quote
  #18  
Old 05-20-2007, 03:28 AM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
I can't seem to get function objects to work as expected:

PHP Code:
public function sampleFunction() {
 return 
this.test this.test2;
}

public function 
someClass() {
obj2 = new TStaticVar();
obj2.test 0;
obj2.test2 0;
obj2.sampleFunction this.sampleFunction;
return 
obj2;
}

function 
onCreated() {
  
newClass someClass();
  
newClass.test 1;
  
newClass.test2 2;
  echo(
newClass.sampleFunction()); //should echo 3?

Even cutting it down:
PHP Code:
 obj2 = new TStaticVar();
  
obj2.test 3;
  
obj2.test2 4;
  
obj2.sampleFunction this.sampleFunction;

  echo(
obj2.sampleFunction()); 
These give errors in RC: GraalScript: Function unknown_object.sampleFunction not accessible at line 12 in script of class_test


Do function objects only work on this. variables?
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #19  
Old 05-20-2007, 03:39 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Quote:
Originally Posted by JkWhoSaysNi View Post
stuff
Well, to be honest I didn't know you could even return objects?

But so far all I've witnessed object functions to be usable with is this. prefix. I tried it with temp and it didn't work for the most part, I'll make sure to test that out again, but I think it should work in general tho.

E: Definitely only useable with this. prefix. The question is if this is so limited, can we get some more effective or in-depth uses of pointer functions. At this time I don't really see the use.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #20  
Old 05-20-2007, 05:37 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 ( func( "blah" ) )

vs.

this.funct = func();
if ( this.funct( "blah" ) )

Any other uses?
That doesn't make any sense to me.
__________________
Reply With Quote
  #21  
Old 05-20-2007, 05:41 AM
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 cbkbud View Post
if ( func( "blah" ) )

vs.

this.funct = func();
if ( this.funct( "blah" ) )

Any other uses?
That doesn't make any sense to me.
>_>
PHP Code:
function onCreated()
{
  if (
func("blah")) {
    
stuff();
  }
}
function 
func(foo) {
  return 
true;

VS
PHP Code:
function onCreated()
{
  
this.funct = function() {
    return 
true;
  };
  if (
this.funct("blah")) {
    
stuff();
  }

is more like it
__________________
Reply With Quote
  #22  
Old 05-20-2007, 05:43 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Point is, this limits the amount of functions you catch and call.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #23  
Old 05-20-2007, 05:47 AM
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 killerogue View Post
Point is, this limits the amount of functions you catch and call.
true
__________________
Reply With Quote
  #24  
Old 05-20-2007, 06:00 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
I honestly think this is useless and is just causing confusion. I get it, but at the same time it still confuses me
Reply With Quote
  #25  
Old 05-20-2007, 06:15 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
I find that the most practical thing about this function thing if for sorting... Basically, passing the function the depicts which value is greater.
Reply With Quote
  #26  
Old 05-20-2007, 09:57 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by cbkbud View Post
if ( func( "blah" ) )

vs.

this.funct = func();
if ( this.funct( "blah" ) )

Any other uses?
That doesn't make any sense to me.
Quote:
Originally Posted by Rapidwolve View Post
I honestly think this is useless and is just causing confusion. I get it, but at the same time it still confuses me
If you do not understand the use of them, I suggest that you learn JavaScript and use them there.

They are very useful for controlling functions at execution time, and they are a lot more organised in event-driven system.
__________________
Skyld
Reply With Quote
  #27  
Old 05-20-2007, 02:00 PM
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
Quote:
Originally Posted by Chompy View Post
>_>
PHP Code:
function onCreated()
{
  if (
func("blah")) {
    
stuff();
  }
}
function 
func(foo) {
  return 
true;

VS
PHP Code:
function onCreated()
{
  
this.funct = function() {
    return 
true;
  };
  if (
this.funct("blah")) {
    
stuff();
  }

is more like it
Is there a point to this?
__________________
Reply With Quote
  #28  
Old 05-20-2007, 02:32 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 cbkbud View Post
Is there a point to this?
Yep

Quote:
Originally Posted by Skyld View Post
If you do not understand the use of them, I suggest that you learn JavaScript and use them there.

They are very useful for controlling functions at execution time, and they are a lot more organised in event-driven system.
Quote:
Originally Posted by killerogue View Post
Point is, this limits the amount of functions you catch and call.
__________________
Reply With Quote
  #29  
Old 05-21-2007, 11:34 PM
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 killerogue View Post
Well, to be honest I didn't know you could even return objects?
A TGraalVar that is an "Object" exists as a reference to the object so no matter where the variable is it will always point to a specific object. And yes, you can return object references.

It is something I used in my mud system, you construct all mud objects in a single array and return the object reference with the function. Having a master list prevents the object from being destroyed because of lack of references. Though I don't know what Graal does when all references are removed, I expect it similar to Java.
__________________
Reply With Quote
  #30  
Old 05-22-2007, 01:06 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Inverness View Post
Though I don't know what Graal does when all references are removed, I expect it similar to Java.
Currently destroying a child staticvar within a parent staticvar leaves a pointer in the parent to the child. Basically it points to 0's. Highly annoying for debugging . Hopefully it will be fixed soon.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 09:16 AM.


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