Game Development Community

quick script question on Schedule()

by Steve · in Torque 3D Professional · 08/07/2009 (8:30 am) · 4 replies

This works for me:

myfunction(%this, %obj)
{
%obj.playAudio(1,"wdywant");
}


But this does not:

myfunction(%this, %obj)
{
schedule(3000,%obj,playAudio,1,"wdywant");
}

Can anyone please tell me why?

#1
08/07/2009 (8:40 am)
You need to schedule member functions from the object itself:

%obj.schedule(3000,playAudio,1,"wdywant");
#2
08/07/2009 (9:04 am)
Thanks, that worked. So, schedule can sometimes be used as a stand alone function, but playAudio is always a member function?
#3
08/07/2009 (9:15 am)
kind of. There are two different schedule functions. One is a straight console function. The second, is a member function of the SimObject class. SimObject is one of the main base classes for all objects in Torque.

Quote: SimObject is a base class for most of the classes you'll encounter
working in Torque. It provides fundamental services allowing "smart"
object referencing, creation, destruction, organization, and location.
Along with SimEvent, it gives you a flexible event-scheduling system,
as well as laying the foundation for the in-game editors, GUI system,
and other vital subsystems.

PlayAudio is a member function of the ShapeBase class. This class is the base object of anything that can be rendered.

Quote: ShapeBase is the renderable shape from which most of the scriptable objects
are derived, including the player, vehicle and items classes. ShapeBase
provides basic shape loading, audio channels, and animation as well as damage
(and damage states), energy, and the ability to mount images and objects.


(note that ShapeBase also derives from SimObject, so you still have all of that functionality on a shapebase (and it's descendents: player, vehicle, etc)
#4
08/07/2009 (12:36 pm)
ok thanks, its working now, and I have additional info to boot.