Has Schedule Syntax Changed?
by Steve Acaster · in Torque 3D Professional · 08/14/2009 (2:13 pm) · 5 replies
Has the schedule syntax changed?
Or are my marbles falling through the holes caused by general wear-and-tear?
//I thought it was %this.schedule(%time, %obj, %function); //but instead I find %this.schedule(%time, %function, %obj);
Or are my marbles falling through the holes caused by general wear-and-tear?
About the author
One Bloke ... In His Bedroom ... Making Indie Games ...
#2
08/14/2009 (5:16 pm)
"it's not the years it's the mileage" ;)
#3
schedule( %time, %obj, %command )
%obj.schedule( %time, %method, %args )
%obj in the schedule "function" is not an object that gets called or used in any way. Its only purpose is to cancel the schedule if that object no longer exists when the time elapses.
08/14/2009 (10:57 pm)
There are two schedules...schedule( %time, %obj, %command )
%obj.schedule( %time, %method, %args )
%obj in the schedule "function" is not an object that gets called or used in any way. Its only purpose is to cancel the schedule if that object no longer exists when the time elapses.
#4
%this.schedule( 2000, %obj, myfunction); or %obj.schedule( 2000, myfunction);
should have been:
%this.schedule( 2000, myfunction, %obj); to make certain teh individual object got passed along for further functions.
08/15/2009 (3:01 am)
Yeah, I think I confused myself, having my "3D Head" on and not my "Script Head" at the moment,I got mixed up with %obj and %args. old age, poverty, persid meteors, etc, etc...%this.schedule( 2000, %obj, myfunction); or %obj.schedule( 2000, myfunction);
should have been:
%this.schedule( 2000, myfunction, %obj); to make certain teh individual object got passed along for further functions.
#5
You will see both types used in the scripts. I tend to think of the first one as an object method and the second one as a global or standalone method that's not attached to any specific object or doesn't depend on any object still existing at the time of the function execution.
And in the interest of consolidating even more scheduling information here's another quote taken from Plastic Gem 32:
08/15/2009 (8:33 am)
James nailed it, but can I help add to the overall confusion? I mean level of knowledge ;)Quote:I think it was Tim Gift who said that (I pulled it from a list of quotes I find more useful than the documentation).
There are two schedule command, one attached to an object, the other not. The object one:
%object.schedule(%time, %command, args....)
or it's equivilent:
schedule( %object, %time, %command, args...)
The second form is essentually the same thing, but allows you to pass 0 for the object argument (the previous form is a method call so you cannot pass it a null object):
schedule(%time, %object, $command, args....)
Here, %object can be 0.
You will see both types used in the scripts. I tend to think of the first one as an object method and the second one as a global or standalone method that's not attached to any specific object or doesn't depend on any object still existing at the time of the function execution.
And in the interest of consolidating even more scheduling information here's another quote taken from Plastic Gem 32:
Quote:
What is a schedule? A schedule allows you to execute some code after an amount of time has elapsed. For instance you might have a cut scene system in which you have the program go to the next part of the cut scene automatically. However what if you allow a person to click thru the cut scene at a faster pace, you must also account for the fact a schedule was initiated and prevent it from executing once the time has elapsed.
First off, we need to know the syntax to use for schedules and a support function for schedules. There are two options for scheduling, a global schedule in which you can call any function you wish or a local schedule in which you call a method on an object.
%id = schedule(%milliseconds, %referanceObject, "functionName", [%Arg1, %Arg2]); %id = %referanceObject.schedule(%milliseconds, "functionName", [%Arg1, %Arg2]);
Quote:
You should notice that the two function calls are essentially the same except one is called on an object while the other can call a global function. It is presumed that if you passed in a %referanceObject into the global function it would call that object's method, instead of a global function. In most cases, though if you are using the global function approach the reference object is set to zero. You might note that I have provided only two parameters in the example, but in actuality there is no limit to how many parameters you pass in to the specified function. Finally you will also notice that the schedule call will return a scheduleId. This is very useful for monitoring the status of the schedule.
Torque 3D Owner Nick "Steve" DeChiara
Default Studio Name
So I subscribe to the holes theory.