A small program that has console output and can run scripts from files.
private static BSEngine CreateEngine()
{
Console.WriteLine( "Creating Script Engine" );
BSEngineSettings settings = BSEngineSettings.MakeDefault();
//Add the Console API so we can write things to the console
settings.Interfaces.Add( new ConsoleApi() );
return settings.Build();
}
private static void Main( string[] args )
{
BSEngine engine = CreateEngine();
if ( args.Length == 0 )
{
Console.WriteLine( "No File Specified" );
return;
}
string script = args[0]; //The Script to Execute
string[] scriptArgs = args.Skip( 1 ).ToArray(); //Skip Script Path for convenience
//Run the Script from File
engine.LoadFile( script, scriptArgs );
}
The example includes some example bad scripts
scripts/helloworld.bs
Prints Hello World
on the console.
Complete Console Output:
Creating Script Engine
Hello World
scripts/print_args.bs
Prints all specified arguments to the console
Complete Console Output:
Creating Script Engine
Argument Count: 3
Argument0
Argument1
Argument2
scripts/print_globals.bs
Prints all global variable names to the console
Complete Console Output:
Creating Script Engine
Console
__G
Environment