uptaded the 5th of june 2006
Architecture of the Torque script
This document is based on
demonstartion starter.fps and racing.fps. The organisation of the
script is used as a basis od the architecture script.
This user guide explains
script architecture and how to customise the code when several missions
To do that in an effcient
way it is
important to know how the scripts are organised in order to put the
right information at the right place and avoid redoundancy.
One of the other point to take into account , it is the load and end of
the mission , the risk after several missions is to overlaod the memory
with script and data as terrain, shape, texture , ... and
down the game until it is impossible to play.
The folowing chapters describe step by step the different level of the
architecture , all the programs, functions listed could be
updated in order to get the result excpected.
Architecture level 0
launch the game from Opertaing System
This describes the main
to put in place the game environment.
Architecture level 1 : T
In this part you have to put in place what is common to all the game
and could be reused at any time in the game.
The scripts launched (and
consequently functions laoded ) are common to all
It is in this part that the client/server should be customised.
level 0 : launch the game from Opertaing System
$mod = name of the
directory where the
scripts and data of the game are stored.
The user launched the script below in unix window :
The environment is set and
parameters are controlled
./main.cs : is automatically called by torqueDemo.bin, the
folowing code is launched by main.cs
- This variables managed the game and the mod to load
$defaultGame = "game";
name of the main mod
$userMods = "creator;" @
You can add mod to this
remove if needed. DeafultGame should be the last one.
"creator" should be removed when the final version of the game is
- This script is done to launch a torque
game whatever the game is , also no customisation are needed at this
level, only parameters could be set as :
-Open a separate console
-Saving event game play log into journal
-Play back a journal
Execute the main.cs script
in the directory send in parameters
this function excutes all
scripts belonging to the directory set in $userMods
this function call all the
function belonging to $userMods/main.cs at the condition that the
function onStart() in the $userMods/main.cs are declared as
- Torque is launched and wait for the
events ( mouse, click , keyboard , scheduler, .... )
The events are defined in
launched by the onStart() function below.
level 1 : Torque game environment
All the scripts are launch
by loaddir and loadmod.
The list of scripts
launched is done by ./main.cs script.
This function load the
to manage the client/server
OnStart() : parent of Onstart() in ./main.cs
This function load the
functions used everywhere in order :
to manage the dialog (GUI).
to manage the audio
onExit() : parent of
Save different parameters
But It seems redundant with game. I don't understand very well.
list of main scripts
the default value of
specific to the client are loaded in memory.
the default value of
specific to the server are loaded in memory.
the value of parameters
specific to the
client to save at the end of the game are loaded in memory.
This parameters could supersseed the ./client/defaults.cs
The value of parameters
specific to the
server to save at the end of the game are loaded in memory.
This parameters could supersseed the ./server/defaults.cs
OnStart() : parent of
This function load
used by the Torque editor
This function could be
updated in order
to improve the editor.
level 2 : client server base initialisation
The function initServer
and initClient are launched by the OnStart function
Initialise the server : it
is just the basement. The hosting of the game is done later on.
If you have only one mission the scripts could be loaded at this stage.
But in case of several missions you have to do it later and
call of the scripts relative to the mission shouled be put in comment.
-The client basement. The
connection to teh server is done later on
-The GUI game
-The configuration and parameters of the client are loaded as saved
If you have only one mission the
scripts could be loaded at this stage. But in case of several missions
you have to do it later and the call of the scripts relative
mission shouled be put in comment.
If $JoinGameAddress is set the client connect directly to the game and
the main menu
If it is not the case the GUI to choose the game host , or join server
is displayed => loadStartup()
Data common to all
the game could be downloaded
The function loadStartup()
displayed a picture during a period of time and launch the main menu
Customise this function if you want to change the splash screen
displayed when the game starts.
level 3 : the main menu
This level displays the
main menu GUI used by the players and launch the different actions in
to host a game,
or to connect to a hosted game
or to play solo.
This program display the
list of mission that could be loaded.
This function is updated
in order to load and start the mission selected
level 4 : load the mission
This new program is
created in order to load and start the mission in different context :
- from a menu
- after an event during the game : the new mission is loade
automatically in function of an event in the game ( a trigger )
This function delete the
context of the previous mission and create the new one
This function initilaise
and load the .cs file specific to use by the game :
mission selected "/mission.cs" ;
/server/scripts/" mission selected "/mission.cs" ;
The scripts specifics to
the mission should be stored into a directory with the same name than
the name of the mission file.
This function should be
used to launch the game after an event. The "startMissionGame" is
level 5 : the game
All the actions of the
players on the game are based on 2 principles :
the actions on the
The player actions on key
or mouse call spefici function defined in this scripts
this script calls the
other scripts needed by the missions
when the scripts are specific to a mission
when the scripts are common to all the missions.
The trigger is started automatically by the core torque in function of
trigger could be associated to one of the datablocks defined with the
editor or defined manually when they are the moving objects or
characters or AI or ...
If a new mission should be
depending on the context, the function tiggered should be updated in
call the mission to load :