Empty %this
by Samuel Marcus · in Torque Game Builder · 11/09/2006 (11:37 pm) · 5 replies
I have a class which can't access %this for some reason... any references to %this come up empty, even a direct call for %this.safeDelete()... other objects can refer to it (for instance, to call the function with the safeDelete in it... I know it gets called because there's an echo after the delete command). Ideas...?
(sorry if this is a common question)
(sorry if this is a common question)
About the author
#2
11/10/2006 (11:18 am)
Ok, I will try that... I had been figuring the %this was implicit (I suppose it half is).
#3
(11): Unknown command safeDelete.
Object (2548) weather -> ScriptObject -> SimObject
This is how I set up the object:
($scene is scenegraph... is there a better way to access this from game.cs than pulling the scenegraph from the sceneWindow2d?)
then when I call (later on)
11/10/2006 (11:37 am)
Ok, adding a swath of %this's to my arguments seems to have fixed some callback problems I was having, but I still can't call safeDelete.(11): Unknown command safeDelete.
Object (2548) weather -> ScriptObject -> SimObject
This is how I set up the object:
%WeatherGod = new ScriptObject()
{
class = weather;
sceneGraph = $scene;
};
%WeatherGod.initializeWeather();
%WeatherGod.addCloud($scene);($scene is scenegraph... is there a better way to access this from game.cs than pulling the scenegraph from the sceneWindow2d?)
then when I call (later on)
function weather::cloudRemoved(%this)
{
%this.addCloud(%this.scenegraph);
%this.safeDelete();
}A cloud gets added and I get that unknown command error. Is it because I am using ScriptObject?
#4
11/10/2006 (11:40 am)
ScriptObject doesn't have safeDelete()... it only has delete() :)
#5
11/10/2006 (11:45 am)
You sir, are a poet and a scholar.
Torque 3D Owner Richard McKinney
Default Studio Name
Your method should look like this:
function MyClass::DoSomething(%this) { %this.DoSomethingElse(); }and I'm guessing it looks like this:
function MyClass::DoSomething() { %this.DoSomethingElse(); // fails because you forgot to include %this in the argument list }