Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Anonymous functions don't delete (https://forums.graalonline.com/forums/showthread.php?t=134270448)

Kirko 01-02-2017 10:30 PM

Anonymous functions don't delete
 
I noticed that these functions don't delete and are stored until I clearVars. Is this normal or should I be doing something to clear them? I tried to destroy the function after I use it but that didn't work.

PHP Code:

function onCreated() {
  
//this.clearVars(); // Will clear it

  
temp.fn = function(result) {
    
printf("Test: %d"result);
  };
  
test(55fn);

  
temp.fn.destroy();  // Function function_2107071_1.destroy not found at line 9

  
echo("Errors: " this.scriptErrors);
  echo(
"Useless crap: " getStringKeys("this.function").size()); // Goes up everyime script is updated
}


function 
test(abcallback) {
  (@ 
callback)(b);



ffcmike 01-03-2017 12:47 AM

The "not found" error kindof makes sense as the variable is not an object. I don't believe there is another solution to clearing these anonymous functions however x_x.

Skyld 01-03-2017 05:20 PM

Quote:

Originally Posted by Kirko (Post 1740751)
I noticed that these functions don't delete and are stored until I clearVars. Is this normal

Certainly isn't.
Quote:

Originally Posted by Kirko (Post 1740751)
or should I be doing something to clear them?

Nope. They should be cleaned up automatically by the garbage collector when leaving scope. This looks like a bug in the script engine.

Kirko 01-07-2017 03:49 AM

Is there anyone that can actually fix or is the bug here to stay :(

fowlplay4 01-07-2017 06:28 AM

try temp.fn = "";

Kirko 01-07-2017 06:22 PM

That didn't seem to work either

Crono 01-07-2017 06:27 PM

Quote:

Originally Posted by fowlplay4 (Post 1740767)
try temp.fn = "";

perhaps temp.fp = "4";

ill show myself out


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

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