$Game::Schedule
by Howard Dortch · in Torque Game Engine · 02/07/2005 (11:50 am) · 4 replies
I have a situation where I set the $Game::Schedule to say 20 min. Should some event occur like flag capture or kill score reached cycleGame is called. In cycleGame there is
$Game::Schedule = schedule(0, 0, "onCycleExec");
and in onCycleExec there is
$Game::Schedule = schedule($Game::EndGamePause * 1000, 0, "onCyclePauseEnd");
When the game loads and startGame() is called we reset the game timer with
$Game::Schedule = schedule($Game::Duration * 1000, 0, "onGameDurationEnd" );
The next mission loads and runs but the game cycles out at exactly the time that was left from the origional mission.
20 minute mission starts, runs for 15 min because someone captured the flag
Game cycles and $Game::Schedule is set to 20 min.
Game exits in 5 min because the cycle timer went off.
It looks to me like there are many instances of $Game::Schedule running. I cancel them everywhere but can't get this to work properly. When a game cycles out and the timer is set to 20 min it should run for 20 min. What am I missing here?
$Game::Schedule = schedule(0, 0, "onCycleExec");
and in onCycleExec there is
$Game::Schedule = schedule($Game::EndGamePause * 1000, 0, "onCyclePauseEnd");
When the game loads and startGame() is called we reset the game timer with
$Game::Schedule = schedule($Game::Duration * 1000, 0, "onGameDurationEnd" );
The next mission loads and runs but the game cycles out at exactly the time that was left from the origional mission.
20 minute mission starts, runs for 15 min because someone captured the flag
Game cycles and $Game::Schedule is set to 20 min.
Game exits in 5 min because the cycle timer went off.
It looks to me like there are many instances of $Game::Schedule running. I cancel them everywhere but can't get this to work properly. When a game cycles out and the timer is set to 20 min it should run for 20 min. What am I missing here?
#2
when the game ends I cancel it
when the score ends the game I cancel it
when the game loads I cancel it
when the game starts I cancel it before it hits the reset.
$Game::Schedule = schedule($Game::Duration * 1000, 0, "onGameDurationEnd" );
then the next game ends on time prematurely it's almost as if there are lots of instances of that running and the actual game schedule is running off the last one at least the times are exact first game runs 15 second runs 5, first game runs 7 second game runs 13....etc the score end calls cycleGame() and the first thing I do in there is cancel($Game::Schedule);
I fixed it by just creating a new clock to do game time and it works fine, just curious why this dont work properly.
02/07/2005 (4:50 pm)
I do that in many places.when the game ends I cancel it
when the score ends the game I cancel it
when the game loads I cancel it
when the game starts I cancel it before it hits the reset.
$Game::Schedule = schedule($Game::Duration * 1000, 0, "onGameDurationEnd" );
then the next game ends on time prematurely it's almost as if there are lots of instances of that running and the actual game schedule is running off the last one at least the times are exact first game runs 15 second runs 5, first game runs 7 second game runs 13....etc the score end calls cycleGame() and the first thing I do in there is cancel($Game::Schedule);
I fixed it by just creating a new clock to do game time and it works fine, just curious why this dont work properly.
#3
function cycleGame()
{
if (!$Game::Cycling) {
// Cancel existing game cycle
if ($Game::Schedule)
{
cancel($Game::Schedule);
}
$Game::Cycling = true;
$Game::Schedule = schedule(0, 0, "onCycleExec");
}
}
--- I added a check function in onGameDurationEnd as well.
function onGameDurationEnd()
{
// This "redirect" is here so that we can abort the game cycle if
// the $Game::Duration variable has been cleared, without having
// to have a function to cancel the schedule.
if ($Game::Duration && !isObject(EditorGui))
{
$Game::Schedule = 0;
cycleGame();
}
}
06/10/2007 (3:25 pm)
I had this problem, and i was able to fix it, by canceling it if cycle game is called.function cycleGame()
{
if (!$Game::Cycling) {
// Cancel existing game cycle
if ($Game::Schedule)
{
cancel($Game::Schedule);
}
$Game::Cycling = true;
$Game::Schedule = schedule(0, 0, "onCycleExec");
}
}
--- I added a check function in onGameDurationEnd as well.
function onGameDurationEnd()
{
// This "redirect" is here so that we can abort the game cycle if
// the $Game::Duration variable has been cleared, without having
// to have a function to cancel the schedule.
if ($Game::Duration && !isObject(EditorGui))
{
$Game::Schedule = 0;
cycleGame();
}
}
Torque Owner Gonzo T. Clown
cancel($Game::Schedule);