How to merge the starter FPS into the common.
by Ryan Mick · 07/04/2005 (2:08 pm) · 28 comments
1. Make a copy of your example directory. Place this copy any where you like,
I placed mine in my torque directory (c:\torque). I renamed the folder FPS.
2. Replace the root main.cs with the one included. The modifications are
simple but would take too long to list out. Basically all I did was to
merge the root main with the Starter.Fps main.
3. Next copy the Starter.Fps/client directory to the common directory.
4. Copy Starter.Fps/data to common.
5. Copy Starter.Fps/server to common.
6. Modify the common/main.cs file with the following:
a. Function initBaseClient, remove:
i. exec("./editor/editor.cs"); and
exec("./editor/particleEditor.cs");
ii. The reason for removing these lines is because we
will be implementing the editors as a mod. That way
deploying the finished game will be easier.
b. Remove the common package section, we don
I placed mine in my torque directory (c:\torque). I renamed the folder FPS.
2. Replace the root main.cs with the one included. The modifications are
simple but would take too long to list out. Basically all I did was to
merge the root main with the Starter.Fps main.
3. Next copy the Starter.Fps/client directory to the common directory.
4. Copy Starter.Fps/data to common.
5. Copy Starter.Fps/server to common.
6. Modify the common/main.cs file with the following:
a. Function initBaseClient, remove:
i. exec("./editor/editor.cs"); and
exec("./editor/particleEditor.cs");
ii. The reason for removing these lines is because we
will be implementing the editors as a mod. That way
deploying the finished game will be easier.
b. Remove the common package section, we don
About the author
#2
Are you extracting the builtin mission editor out of the client into another client to obtain the effect of a dedicate playing client (without mission, world, etc editing capabilities like most other games) and have a separate dedicated mission/world building editor?
If this is the case, you just answered one of my questions I was planning to ask, that is how to disable the mission/world editor for player clients.
07/05/2005 (6:52 am)
Just a question to clarify what is happening here.Are you extracting the builtin mission editor out of the client into another client to obtain the effect of a dedicate playing client (without mission, world, etc editing capabilities like most other games) and have a separate dedicated mission/world building editor?
If this is the case, you just answered one of my questions I was planning to ask, that is how to disable the mission/world editor for player clients.
#3
07/05/2005 (6:57 am)
Awesome... thx
#4
07/05/2005 (7:13 am)
Rizzen, basically that is correct. The editors have been removed from the base and implemented as a mod. All you have to do when you deploy your game is change one line and remove the editors folder.
#5
07/05/2005 (7:25 am)
Nice work. This is pretty handy.
#6
07/05/2005 (7:31 am)
Very cool, thanks.
#7
Thanx for this incredible great resource you giving to the community!
:)
07/06/2005 (4:37 am)
Fantastic work Ryan Mick!Thanx for this incredible great resource you giving to the community!
:)
#8
07/06/2005 (7:44 am)
Thanks everyone. I just wanted to give something back to the community, and it was hard to start on a game with the way the demos were set up. It always felt to me like I was making a mod and not a game. I decided to mod the editors to make it easier to deploy a game since it looked like no one had attempted to do so in the past. Have fun with it!
#9
I think I have a small problem, I done the changes you mentioned. When I attempt to run the game, I only obtain % on the command line that does not seem to respond to any input.
07/06/2005 (10:56 am)
I hope one day I will contribute something worth while to the community.I think I have a small problem, I done the changes you mentioned. When I attempt to run the game, I only obtain % on the command line that does not seem to respond to any input.
#10
07/06/2005 (12:20 pm)
Try deleteing all DSO's, and restarting the application. Sometimes the DSO's don't get recompiled for some reason.
#11
the example/runtorque.sh starts correct without any errors.
the fps/runtorque.sh just gives the % on the commandline.
PS: I using Linux.
07/07/2005 (7:27 am)
I don't seem to have any DSO files at all, where are they normally located.the example/runtorque.sh starts correct without any errors.
the fps/runtorque.sh just gives the % on the commandline.
PS: I using Linux.
#12
07/07/2005 (8:57 am)
DSO files are located in the same location as the CS files. When you run Torque it will compile the CS files into DSO's. The only file that does not get compiled is the root main.cs. When you copied the new root main above did you clean it up after you pasted? Unfortunalty the forum causes line breaks in places were there should not be any. Look through the main and make sure that everything is in it correct place. Is ther anything in your console log?
#13
Though I seem to be just mising the grass texture, have the ground texture visible.
Pressing F10 and F11 is still envoking the builtin editor. Is this correct?
How is one suppose to evoke the editor without starting the player client?
07/07/2005 (9:47 am)
Thanx, it was the main.cs, extra line breaks was the cause.Though I seem to be just mising the grass texture, have the ground texture visible.
Pressing F10 and F11 is still envoking the builtin editor. Is this correct?
How is one suppose to evoke the editor without starting the player client?
#14
F10 and F11 still load up the editors.
You have to launch the client to use the editors. Basically it's all real time editing, though it would be nice if the GUI editor had a code window to enter in code for the GUI with out having open the file in a text editor.... hmmm maybe I should look into that next??
Let me know if you have anymore questions.
07/07/2005 (10:32 am)
To fix the ground textures you will need to reload them in the texture browser (part of the mission editor F11). Once you remap them you will need to save the mission file to persist their new location.F10 and F11 still load up the editors.
You have to launch the client to use the editors. Basically it's all real time editing, though it would be nice if the GUI editor had a code window to enter in code for the GUI with out having open the file in a text editor.... hmmm maybe I should look into that next??
Let me know if you have anymore questions.
#15
There is not much change in the overall effect of the client at runtime, basicly just a reorganization of the client scripts to make a clear separation between editor code from the game player client code. It actually does not separate the editor out of the client at runtime.
Just to make sure, what is the benefeit of this resource seeing I did miss the intent of the resource in the beginning?
Is there a way to completely disable the editor out of the player client and have them in a separate editor client?
07/07/2005 (11:03 am)
I think I misunderstood what the intent of this resource.There is not much change in the overall effect of the client at runtime, basicly just a reorganization of the client scripts to make a clear separation between editor code from the game player client code. It actually does not separate the editor out of the client at runtime.
Just to make sure, what is the benefeit of this resource seeing I did miss the intent of the resource in the beginning?
Is there a way to completely disable the editor out of the player client and have them in a separate editor client?
#16
The editors are seperated from the client at run time. I say this because they are loaded as a mod and are no longer part of the common code base.
In the root main.cs change:
To
Now when your run your game there are no editors available but you can still play the game. You can leave the line like that and create a short cut or batch file that calles the exe with -mod editor switch to enable the editors for your self or your team as you develop the game. When you distribute the game just don't include the editor folder. You will always have the version of your game you develop with and the version of your game you distribute to players. Theres just no getting around that. When you distribute to players you don't want to include your CS file, other wise they will be able to modify your source code and create their own game.
I hope that helps.
07/07/2005 (12:08 pm)
Yes this is a re-organization of the client scripts.The editors are seperated from the client at run time. I say this because they are loaded as a mod and are no longer part of the common code base.
In the root main.cs change:
$defaultGame = "editor";
To
$defaultGame = "";
Now when your run your game there are no editors available but you can still play the game. You can leave the line like that and create a short cut or batch file that calles the exe with -mod editor switch to enable the editors for your self or your team as you develop the game. When you distribute the game just don't include the editor folder. You will always have the version of your game you develop with and the version of your game you distribute to players. Theres just no getting around that. When you distribute to players you don't want to include your CS file, other wise they will be able to modify your source code and create their own game.
I hope that helps.
#17
Once again, thanx for this excellent resource you provided to the community. :)
07/08/2005 (4:14 am)
Thanx for the explaination, now I fully understand how this resource is meant to be used.Once again, thanx for this excellent resource you provided to the community. :)
#18
07/19/2005 (8:48 am)
Is it me or were the editors split to their own directory in HEAD (1.4)?
#19
07/19/2005 (6:33 pm)
From what I hear the editors are split up in the 1.4 release canidates. But if you are not using them, this will walk you through the process of splitting out the editors on your own.
#20
07/20/2005 (7:26 am)
Ahhh. Gotcha. (C; 
Torque Owner Ryan Mick
Red Witch Entertainment
//----------------------------------------------------------------------------- // Torque Game Engine // Copyright (C) GarageGames.com, Inc. //----------------------------------------------------------------------------- $defaultGame = "editor"; $displayHelp = false; EnableWinConsole(true); //----------------------------------------------------------------------------- // Support functions used to manage the mod string function pushFront(%list, %token, %delim) { if (%list !$= "") return %token @ %delim @ %list; return %token; } function pushBack(%list, %token, %delim) { if (%list !$= "") return %list @ %delim @ %token; return %token; } function popFront(%list, %delim) { return nextToken(%list, unused, %delim); } //------------------------------------------------------------------------------ // Process command line arguments // TorqueDebugPatcher begin $GameDebugEnable = false; $GameDebugPort = 28040; $GameDebugPassword = "password"; function doEnableDebug() { // attempt to auto enable debugging if (!$GameDebugEnable) { echo("NOT enabling debug..."); return; } echo("DEBUG: enabling debug on port: " @ $GameDebugPort); %cmd = "dbgSetParameters(" @ $GameDebugPort @ "," @ $GameDebugPassword @ ");"; echo("DEBUG: evaluating: " @ %cmd); eval(%cmd); } // TorqueDebugPatcher end $modcount = 0; $userMods = $defaultGame; //----------------------------------------------------------------------------- // The displayHelp, onStart, onExit and parseArgs function are overriden // by mod packages to get hooked into initialization and cleanup. function onStart() { echo("\n--------- Initializing FPS ---------"); // Load the scripts that start it all... exec("common/client/init.cs"); exec("common/server/init.cs"); exec("common/data/init.cs"); initCommon(); // Server gets loaded for all sessions, since clients // can host in-game servers. initServer(); // Start up in either client, or dedicated server mode if ($Server::Dedicated) initDedicated(); else initClient(); } function onExit() { echo("Exporting client prefs"); export("$pref::*", "common/client/prefs.cs", False); echo("Exporting client config"); if (isObject(moveMap)) moveMap.save("common/client/config.cs", false); echo("Exporting server prefs"); export("$Pref::Server::*", "common/server/prefs.cs", False); BanList::Export("common/server/banlist.cs"); } function parseArgs() { for ($i = 1; $i < $Game::argc ; $i++) { $arg = $Game::argv[$i]; $nextArg = $Game::argv[$i+1]; $hasNextArg = $Game::argc - $i > 1; $logModeSpecified = false; switch$ ($arg) { //-------------------- // TorqueDebugPatcher begin case "-dbgPort": // we must have a next arg $argUsed[$i]++; if ($hasNextArg) { $GameDebugPort = $nextArg; $argUsed[$i+1]++; $i++; } else error("Error: Missing Command Line argument. Usage: -dbgPort <port>"); //-------------------- case "-dbgPassword": // we must have a next arg $argUsed[$i]++; if ($hasNextArg) { $GameDebugPassword = $nextArg; $argUsed[$i+1]++; $i++; } else error("Error: Missing Command Line argument. Usage: -dbgPassword <password>"); //-------------------- case "-dbgEnable": $GameDebugEnable = true; $argUsed[$i]++; //-------------------- case "-connect": $argUsed[$i]++; if ($hasNextArg) { // mark which server we will automatically connect to setAutoConnect($nextArg); $argUsed[$i+1]++; $i++; } else error("Error: Missing Command Line argument. Usage: -connect <x.x.x.x:port>"); // TorqueDebugPatcher end //-------------------- case "-log": $argUsed[$i]++; if ($hasNextArg) { // Turn on console logging if ($nextArg != 0) { // Dump existing console to logfile first. $nextArg += 4; } setLogMode($nextArg); $logModeSpecified = true; $argUsed[$i+1]++; $i++; } else error("Error: Missing Command Line argument. Usage: -log <Mode: 0,1,2>"); //-------------------- case "-mod": $argUsed[$i]++; if ($hasNextArg) { // Append the mod to the end of the current list $userMods = strreplace($userMods, $nextArg, ""); $userMods = pushFront($userMods, $nextArg, ";"); $argUsed[$i+1]++; $i++; $modcount++; } else error("Error: Missing Command Line argument. Usage: -mod <mod_name>"); //-------------------- case "-game": $argUsed[$i]++; if ($hasNextArg) { // Remove all mods, start over with game $userMods = $nextArg; $argUsed[$i+1]++; $i++; $modcount = 1; } else error("Error: Missing Command Line argument. Usage: -game <game_name>"); //-------------------- case "-show": // A useful shortcut for -mod show $userMods = strreplace($userMods, "show", ""); $userMods = pushFront($userMods, "show", ";"); $argUsed[$i]++; $modcount++; //-------------------- case "-console": enableWinConsole(true); $argUsed[$i]++; //-------------------- case "-jSave": $argUsed[$i]++; if ($hasNextArg) { echo("Saving event log to journal: " @ $nextArg); saveJournal($nextArg); $argUsed[$i+1]++; $i++; } else error("Error: Missing Command Line argument. Usage: -jSave <journal_name>"); //-------------------- case "-jPlay": $argUsed[$i]++; if ($hasNextArg) { playJournal($nextArg,false); $argUsed[$i+1]++; $i++; } else error("Error: Missing Command Line argument. Usage: -jPlay <journal_name>"); //-------------------- case "-jDebug": $argUsed[$i]++; if ($hasNextArg) { playJournal($nextArg,true); $argUsed[$i+1]++; $i++; } else error("Error: Missing Command Line argument. Usage: -jDebug <journal_name>"); //------------------- case "-help": $displayHelp = true; $argUsed[$i]++; //-------------------- case "-dedicated": $Server::Dedicated = true; enableWinConsole(true); $argUsed[%i]++; //-------------------- case "-mission": $argUsed[%i]++; if (%hasNextArg) { $missionArg = %nextArg; $argUsed[%i+1]++; %i++; } else error("Error: Missing Command Line argument. Usage: -mission <filename>"); //-------------------- case "-connect": $argUsed[%i]++; if (%hasNextArg) { $JoinGameAddress = %nextArg; $argUsed[%i+1]++; %i++; } else error("Error: Missing Command Line argument. Usage: -connect <ip_address>"); //------------------- default: $argUsed[$i]++; if($userMods $= "") $userMods = $arg; } } if($modcount == 0 && ($defaultGame !$= "")) { $userMods = $defaultGame; $modcount = 1; } } // Parse the command line arguments echo("--------- Parsing Arguments ---------"); parseArgs(); package Help { function onExit() { // Override onExit when displaying help } }; function displayHelp() { activatePackage(Help); // Notes on logmode: console logging is written to console.log. // -log 0 disables console logging. // -log 1 appends to existing logfile; it also closes the file // (flushing the write buffer) after every write. // -log 2 overwrites any existing logfile; it also only closes // the logfile when the application shuts down. (default) error( "Torque Demo command line options:\n"@ " -log <logmode> Logging behavior; see main.cs comments for details\n"@ " -game <game_name> Reset list of mods to only contain <game_name>\n"@ " <game_name> Works like the -game argument\n"@ " -mod <mod_name> Add <mod_name> to list of mods\n"@ " -console Open a separate console\n"@ " -show <shape> Launch the TS show tool\n"@ " -jSave <file_name> Record a journal\n"@ " -jPlay <file_name> Play back a journal\n"@ " -jDebug <file_name> Play back a journal and issue an int3 at the end\n"@ // TorqueDebugPatcher begin " -dbgPort <port> Set debug port (default = 28040)\n"@ " -dbgPassword <pass> Set debug password (default = password)\n"@ " -dbgEnable Start game in debug mode\n"@ // TorqueDebugPatcher end " -dedicated Start as dedicated server\n"@ " -connect <address> For non-dedicated: Connect to a game at <address>\n" @ " -mission <filename> For dedicated: Load the mission\n" @ " -help Display this help message\n" ); } //-------------------------------------------------------------------------- // Default to a new logfile each session. if (!$logModeSpecified) { setLogMode(6); } // Set the mod path which dictates which directories will be visible // to the scripts and the resource engine. setModPaths($userMods); // Get the first mod on the list, which will be the last to be applied... this // does not modify the list. nextToken($userMods, currentMod, ";"); // Execute startup scripts for each mod, starting at base and working up function loadDir(%dir) { setModPaths(pushback($userMods, %dir, ";")); exec(%dir @ "/main.cs"); } echo("--------- Loading Common ---------"); //Added to create a single base // Load up common script base loadDir("common"); //setModPaths("common"); //----------------------------------------------------------------------------- // Load up defaults console values. // Defaults console values exec("common/client/defaults.cs"); exec("common/server/defaults.cs"); // Preferences (overide defaults) exec("common/client/prefs.cs"); exec("common/server/prefs.cs"); echo("--------- Loading MODS ---------"); function loadMods(%modPath) { %modPath = nextToken(%modPath, token, ";"); if (%modPath !$= "") loadMods(%modPath); if(exec(%token @ "/main.cs") != true){ error("Error: Unable to find specified mod: " @ %token ); $modcount--; } } if($modcount != 0) { loadMods($userMods); echo(""); } // Either display the help message or startup the app. if ($displayHelp) { enableWinConsole(true); displayHelp(); quit(); } else { onStart(); echo("Engine initialized..."); // TorqueDebugPatcher begin doEnableDebug(); // TorqueDebugPatcher end } // Display an error message for unused arguments for ($i = 1; $i < $Game::argc; $i++) { if (!$argUsed[$i]) error("Error: Unknown command line argument: " @ $Game::argv[$i]); }