How to control the amount of time a user can play a game or mission?
by Maria C R Harrington · in Torque 3D Professional · 04/15/2011 (6:43 am) · 4 replies
In server/scripts/game.cs, I have set $Game::Duration = 0; to allow the end user unlimited play time, but it does not work. Other time amounts instead of "0" such as "5" or "60" do not change the play time from the original "20" minutes.
Are there any other variables to check?
What other parts of the FPS Demo that control the time?
Are there any other variables to check?
What other parts of the FPS Demo that control the time?
About the author
Virtual Field Trips,LLC specializes in the design, production and publication of simulations and virtual environments for learning and entertainment. Simulations for Exploration, Discovery, and Intrinsic Learning Designed for the Young Child in All of Us.
#2
04/15/2011 (9:53 am)
Steve's on the right track... but it's looking like the duration variable isn't being set/read/used correctly -- something might have gotten missed when things got trimmed down to the example scripts we have now.
#3
EDIT: I'll go ahead and post a bug report since I'm already here.
To fix the problem, simply go into scripts/server/gameCore.cs, find function startGame() and change this:
Hope that helps... I think that's all I changed.
04/15/2011 (2:55 pm)
Ok, this is bugged. I would suggest editing the post to reflect the desired bug report format so that it can be acknowledged and fixed -- seems they need that sort of extra help ;)EDIT: I'll go ahead and post a bug report since I'm already here.
To fix the problem, simply go into scripts/server/gameCore.cs, find function startGame() and change this:
// Start the game timer
if ($Game::Duration)
$Game::Schedule = schedule($Game::Duration * 1000, 0, "onGameDurationEnd");to:// Start the game timer
if ($Game::Duration)
$Game::Schedule = %game.schedule($Game::Duration * 1000, "onGameDurationEnd");// this line changedNext, in function onGameDurationEnd() you'll have to change it so that it knows the %game variable (which is our gametype script object) as all other functions do. This will allow cycleGame to be properly called once the time limit expires.function GameCore::onGameDurationEnd(%game) // changed here
{
//echo (%game @"\c4 -> "@ %game.class @" -> GameCore::onGameDurationEnd");
if ($Game::Duration && !isObject(EditorGui))
%game.cycleGame(); // changed here
}Or you can technically just make use of %this, the function automatically knows what %this is. I just showed the above to make it consistent with the rest of the script.unction GameCore::onGameDurationEnd()
{
//echo (%game @"\c4 -> "@ %game.class @" -> GameCore::onGameDurationEnd");
if ($Game::Duration && !isObject(EditorGui))
%this.cycleGame(); // changed here
}And lastly, in gameDM.cs (the default gametype if one isn't stated in the mission file) look for function initGameVars() and it has the overridden value for the default $Game::Duration global that was found in game.cs.// Set the gameplay parameters %game.duration = 30 * 60; // Change this to affect the time limit. %game.endgameScore = 20; %game.endgamePause = 10; $Game::EndGameScore = 20;Some thought should probably be given to making this override a bit more flexible/dynamic.
Hope that helps... I think that's all I changed.
#4
04/15/2011 (3:05 pm)
Oh, and it also looks like the endGame Gui takes no account of the EndGamePause variable so it doesn't actually cycle to the next mission once time expires.
Associate Steve Acaster
[YorkshireRifles]