Author Topic: Schedule Help!  (Read 786 times)

Sorry I have been posting so much, I am just learning TorqueScript.

Anyway, I am making a simple script that counts seconds but it's not working. It just says "Seconds: 1" the entire time.

Here is the code:

Code: [Select]
package Test {

function serverCmdStartTest(%seconds) {

tick();

}

function tick(%seconds) {

%seconds++;

bottomPrintAll("\c6Seconds: \c0"@%seconds ,2);

schedule(1000,0,tick);
}
};
activatePackage(Test);

in a sechedule, it is formatted:


schedule( time in milliseconds, 0, function to call, variables, variables, variables );

so, to fix this near the bottom you'd do

Code: [Select]
function serverCmdStartTest(%seconds) {

tick();

}

function tick(%seconds) {

%seconds++;

bottomPrintAll("\c6Seconds: \c0"@%seconds ,2);

schedule(1000,0,tick,%seconds);
}

also; you don't need to package it.

by the way; you're probably not very picky but i've noticed that torque isn't quite so precise with its timings. when I made a clock mod earlier back, after several (6+) hours, itd tick the next minute about 15 seconds late.
« Last Edit: June 12, 2010, 01:49:21 PM by Triple Nickels »

in a sechedule, it is formatted:


schedule( time in milliseconds, 0, function to call, variables, variables, variables );

so, to fix this near the bottom you'd do

Code: [Select]
-snip-also; you don't need to package it.

Thank you! I know, I just package them because of my OCD. =\

Thank you! I know, I just package them because of my OCD. =\
wat? packaging would make it less efficient so your OCD should make it so you don't package it.

wat? packaging would make it less efficient so your OCD should make it so you don't package it.

Lol, but sometimes things need to be packaged though.

You only need to package if you are using something like Player::activatestuff, so that it does not overwrite the original script. If you are using a function like that which is not a main blockland function (as in not a default action/console command) then you do not need to package. Dunno really how i know this lol, i have only started TS a week ago...yet i have learned a few things.