Problem scheduling a class function in the scripts
by Mike Stoddart · in Torque Game Engine · 08/08/2002 (1:33 pm) · 2 replies
I have the following:
Followed by:
However, this scheduled function is never executed. I'm pretty sure that the %this object that I'm scheduling this function call on is correct. Both functions belong to the WaltherImage class, so it should work.
Can anyone see anything obvious here? I'm really confused by this!
Thanks
function WaltherImage::ReloadAmmoClip(%this, %obj)
{
...
...
%this.schedule(2000, 0, "reloadComplete", %this, %obj);
}Followed by:
function WaltherImage::reloadComplete(%this, %obj)
{
echo("Walther::reloadComplete - Reloading is now complete");
}However, this scheduled function is never executed. I'm pretty sure that the %this object that I'm scheduling this function call on is correct. Both functions belong to the WaltherImage class, so it should work.
Can anyone see anything obvious here? I'm really confused by this!
Thanks
Torque 3D Owner Robert Blanchet Jr.
function WaltherImage::ReloadAmmoClip(%this, %obj) { ... ... %this.schedule(2000, "reloadComplete", %obj); } function WaltherImage::reloadComplete(%this, %obj) { echo("Walther::reloadComplete - Reloading is now complete"); }I guess a little explaination is needed :p
Basically
is the same thing as
except it is a scheduled event. The %this parameter needs to be explicatley used in the function parameter but it should never be explicatley used as a param when calling that function. In other words:
function SomeMethod::someFunction(%this, %aParam) { // do something } function SomeMethod:anotherFunction(%this) { // no, incorrect %this.someFunction(%this, false); // yes, correct usage %this.someFunction(false); }