Graal Forums  

Go Back   Graal Forums > Graal V6 forums > Feature request
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 01-05-2009, 04:56 PM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm will become famous soon enough
discard #varname#;

A minor item for further cranking up the efficiency of complex NPCs. Limits the scope of a variable by declaring it will no longer be used. For instance:

for(this.i=0;this.i<playerscount;this.i++){
...
}
discard this.i; //implicit

because you're unlikely to care that this.i still =playerscount an hour later. Would avoid the usual scripting mess of having one NPC with 70 variables, all of which were intended to be temporary but are still holding floating-point data; granted, that's only 70bytes, but it adds up.
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #2  
Old 01-05-2009, 05:02 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Or you can use temp. variables that clear themselves after the current function scope.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #3  
Old 01-05-2009, 10:06 PM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm will become famous soon enough
Oops, well said, nm...how did I miss those?...
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #4  
Old 01-05-2009, 11:38 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
You could also declare

PHP Code:
this.null
and the variable is then forgotten.
__________________
Reply With Quote
  #5  
Old 01-06-2009, 03:15 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 cbk1994 View Post
You could also declare

PHP Code:
this.null
and the variable is then forgotten.
Wouldn't bet on that one. Vars you have set to nil or null in the past still appear in database npcs, too. When you set them to an empty string, they dont.
__________________
Reply With Quote
  #6  
Old 01-06-2009, 03:47 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
Wouldn't bet on that one. Vars you have set to nil or null in the past still appear in database npcs, too. When you set them to an empty string, they dont.
clearEmptyVars();
__________________
Reply With Quote
  #7  
Old 01-06-2009, 05:26 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 Chompy View Post
clearEmptyVars();
I still remember Stefan's answer when I tried this and it didn't work. His "hm" had like 7 Ms.
__________________
Reply With Quote
  #8  
Old 01-06-2009, 06:59 PM
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
You can also use rungarbagecollector() to clear any links to non-existent variables or objects, although the engine should normally do this eventually.
Reply With Quote
  #9  
Old 01-07-2009, 03:33 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
Quote:
Originally Posted by Crow View Post
Wouldn't bet on that one. Vars you have set to nil or null in the past still appear in database npcs, too. When you set them to an empty string, they dont.
That's weird. Probably would be removed when the garbage collector runs, as Skyld said.

In Java you can destroy an object by destroying all links to that object; I assumed the same would work in GS2, but I guess not, or not reliably.
__________________
Reply With Quote
  #10  
Old 01-07-2009, 05:58 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Crow View Post
Wouldn't bet on that one. Vars you have set to nil or null in the past still appear in database npcs, too. When you set them to an empty string, they dont.
Wrong. Variables/arrays disappear when set to NULL, strings disappear when set to "" (empty string), and TStaticVar's when clearVars()'ed. At least if my memory serves me right.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #11  
Old 01-07-2009, 06:59 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 xXziroXx View Post
Wrong. Variables/arrays disappear when set to NULL, strings disappear when set to "" (empty string), and TStaticVar's when clearVars()'ed. At least if my memory serves me right.
This doesn't always apply to variables when working with database npcs.
This is what clearEmptyVars(); is good for, clearing all empty vars (0 as value for example) in the current object scope.
__________________
Reply With Quote
  #12  
Old 01-07-2009, 06:59 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 xXziroXx View Post
Wrong. Variables/arrays disappear when set to NULL, strings disappear when set to "" (empty string), and TStaticVar's when clearVars()'ed. At least if my memory serves me right.
If you are refering to database npcs as well, you are still somewhat wrong. I thought it would make sense that variables disappear when setting them to nil, so I did exactly that. Before I did it, the variable was holding an integer number. And if I recall correctly, it's the same problem with arrays. But it works for me all the time using an empty string. Don't ask me why, I don't even bother anymore, I already accepted all the weird stuff Graal has to offer a long time ago.
__________________
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 12:20 AM.


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