![]() |
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. |
Or you can use temp. variables that clear themselves after the current function scope.
|
Oops, well said, nm...how did I miss those?...
|
You could also declare
PHP Code:
|
Quote:
|
Quote:
|
Quote:
|
You can also use rungarbagecollector() to clear any links to non-existent variables or objects, although the engine should normally do this eventually.
|
Quote:
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. |
Quote:
|
Quote:
This is what clearEmptyVars(); is good for, clearing all empty vars (0 as value for example) in the current object scope. |
Quote:
|
| All times are GMT +2. The time now is 05:47 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.