Game Development Community

Passing parameters TO a script

by Andrew Bangs · in Torque Game Builder · 11/20/2005 (2:21 pm) · 2 replies

I'd like to have my program run differently, based on which command line argument is passed.

It's passing along nicely until it gets to the main.cs in my mod's directory (the main.cs in the root directory calls onStart, and I pass it through there).

Then it just calls exec("./client/client.cs");

Is there any way for it to pass my variable ($DVall) through to the client.cs?


main.cs in the root directory (with T2D.exe)
//--------------------------------------------------------------------------
// Either display the help message or startup the application.
//--------------------------------------------------------------------------

// Are we displaying help?
if ( $displayHelp )
{
	// Yes, so enable console.
	enableWinConsole(true);
	// Display Help.
	displayHelp();
	// Quit!
	quit();
}
else
{
	// Start-up the script mods.
	onStart($DVall);
	// User Info.
	echo("T2D Engine initialized...");
}

main.cs in my mod's directory
// Start-up.
	function onStart($DVall)
	{
		Parent::onStart();
		echo("\n--------- Welcome to Double Vision ---------");
		
      // Load GUIs
      exec("./client/splashScreen.gui");
      exec("./client/t2d_launchMenu_DoubleVision.gui");   
      exec("./client/t2d_exitScreen.gui");
      
      // Load execution scripts
      exec("./client/client.cs");
		
      loadStartup();
	}

Thanks.

#1
11/20/2005 (4:52 pm)
Well, I figured out my own problem, but just in case someone else stumbles across this:

Global variables are automagically passed to a function's children, or at least their scripts. $DVall was present in my ./client/client.cs script.
#2
11/21/2005 (11:02 am)
Global variables should exist in the entire script space, local variables get destroyed at end of function :)