Game Development Community

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:

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

#1
08/08/2002 (1:43 pm)
Try this:
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
%this.schedule(2000, "reloadComplete", %obj);
is the same thing as
%this.reloadComplete(%obj);
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);
}
#2
08/08/2002 (1:45 pm)
Ok, thanks Robert. That did the trick.