Game Development Community

Delete an object so that it can't be referenced anymore

by gamer · in Torque Game Engine · 10/24/2006 (6:27 pm) · 3 replies

I have new ScriptObject(Test){};
Test.delete();
deleteVariables("Tes*");

Test can still be referenced afterwards, is there a way to delete it completely?

#1
10/24/2006 (7:25 pm)
You can delete objects, and you can re-assign variable values.

I think the closest you can get is:
Test.delete();
Test = "";

Why does this matter to you?
#2
10/25/2006 (12:37 pm)
If I have %test= new ScriptObject(Test){}; I can do test="", but not Test="";
hence it's impossible to really dereference Test.
I am just curious..
#3
10/25/2006 (12:53 pm)
If you Have two or more objects with the same name, you can get this behavior.

Example:
new ScriptObject(Test){};
Test.x = 1;
new ScriptObject(Test){};
Test.x = 2;
echo(Test.x); //should write 2
Test.delete();
echo(Test.x); //should write 1
Test.delete();
echo(Test.x); //should write *nothing*

these Objects exist in Global Scope, so they could be created in another function in another moment.

If you wish to create a lot of objects, work with it, then delete, try keep only the ID of those objects.
Like that:
%id = new ScriptObject();
%id.x = 1;
echo(%id.x);
%id.delete();

I hope this helps.