Game Development Community

Questions about command-line arguments and engine initialization

by Chin Liu · in Torque 3D Professional · 01/18/2010 (4:56 am) · 5 replies

Hi,

I have some questions about the flow of the engine (i.e. how the engine initializes itself to start up the game).

I run Torque 3D 2009 SDK 1.0.1 with Windows XP SP3.

I am trying to understand the scripting files under \Torque\Torque 3D 2009 SDK 1.0.1\Examples\FPS Example\game.

Now, let me ask my questions.

1)Under the directory: \Torque\Torque 3D 2009 SDK 1.0.1\Examples\FPS Example\game, I find a main.cs file. Is this script file the very first script file executed by the engine?


2)In the main.cs, which is mentioned in question 1), I find the following for-loop statement:

for ($i = 1; $i < $Game::argc ; $i++)
{


}

I understand that the global variable, $Game::argc, will be filled by the engine with command-line arguments. I also understand that the command-line can be input by first selecting Start -> Run…, and then enter cmd in the Run dialog. By doing so, the command prompt will be opened for you to input the command line. Now, my question is: what is the format of the command line? Is there any documentation that talks about it?


3)When I tried to run the FPS Example, I did the following steps:
a. Select Start -> All Programs -> Torque\Torque 3D 2009 SDK 1.0.1
b. The Torque Toolbox will be displayed
c. Under the Projects tab, click to select the FPS Example
d. On the right of the Torque Toolbox, click the Play Game button
e. The engine now displays the message: Launching Project
f. The engine now displays the title screen of the game
g. Press the play button
h. Choose level and then press the Go button
i. The game launches
As can be seen from the above steps that I took to launch the game, I did not enter any command line at all! So, my question is: how did the engine fill the global variable, $Game::argc, with command-line arguments, if I did not enter any command line at all when launching the game?


Sorry about my long questions

Thanks


#1
01/18/2010 (5:07 am)

1) Yes, exactly.

2) Not sure about documentation but finding out what options are available and what they do is quite easy. Just grep the scripts for "function parseArgs()" and take a look at the function definitions. Most of this is very self-explanatory (like, for example, "-fullscreen").

3) The toolbox launches the engine directly and supplies command-line arguments (if necessary). This happens in the toolbox code.
#2
01/18/2010 (1:39 pm)
Hi, Rene, thank you for answering my questions.

For Answer 3 provided by Rene, I want to ask some questions about it.

If my understanding is correct, Rene indicated that the C++ code of the Toolbox supplies the global variable, $Game::argc, with command-line arguments, so it means that this command line is hidden in the C++ code of the engine. Now, I want to ask the following questions.

1)If this command line is written in the C++ code of the toolbox, then this command line is NOT written specifically for the FPS Example. If this is the case, does it mean every time when you launch a project through the Toolbox, this command line will be provided as a default command line for the engine to parse?


2)How can I launch the project through the Toolbox using my OWN command line? Where do I input this command line of my own in the Toolbox?


3)Can anyone please (very please) tell me where I can find the command line, which is mentioned by Rene, in the C++ code of the toolbox?

Thanks
#3
01/18/2010 (1:55 pm)

1) When creating the engine process after initiating a startup from the toolbox, the toolbox passes a commandline to the process to instruct the engine to do various things, like e.g. bringing up the GUI selector or loading a level to play or edit. This is all scripted behavior found in core/.

2) You can't AFAIK. For launching with custom command-lines, either use shortcut files, launch from the console, set up a .bat/command file, or provide the args from within the IDE.

3) The toolbox code isn't included in the SDK AFAIK and you probably wouldn't want to go through the trouble of recompiling that (needs Qt).
#4
01/18/2010 (5:16 pm)
You can launch with command arguments from Torsion and VS. I use that to launch directly into the world editor.

For more details, please refer to this thread:
www.torquepowered.com/community/forums/viewthread/109129


If you can make it work for VS I would appreciate that you send me a line (or reply the thread)
#5
01/18/2010 (8:27 pm)
Hi William

In your post, there is one thing I don't understand.

If I understand your post correctly, you want to launch the world editor from the Visual Studio using Command line. However, in this topic that I created, I was asking about using Command line to launch the actually game from the Toolbox.

I am sorry if my understanding is incorrect.