public static int Main(string[] args) { #if DEBUG args = "-s example.js -w ./world -x 0 -y 4 -z 0".Split(' '); #endif #if !DEBUG try { #endif Options options = new Options(); Parser cmdParser = new Parser(); if (!cmdParser.ParseArguments(args, options)) throw new ArgumentException("Invalid Commandline parameter!"); IntVector3 position = default(IntVector3); if (options.Output) { if (options.PositionY != 0) { position = new IntVector3(); position.x = options.PositionX; position.y = options.PositionY; position.z = options.PositionZ; } } JsScriptExecutor executor = new JsScriptExecutor(); executor.Run(options.LibPath, options.ScriptFile, options.WorldDirectory, position, options.IsSchematic); #if !DEBUG } catch (Exception e) { Console.WriteLine("An Error of type {0} occured!", e.GetType()); Console.WriteLine("Error Message: {0}", e.Message); return 1; } #endif return 0; }
private void onGenerateButtonClick(object sender, RoutedEventArgs ev) { tbConsole.Clear(); if (!Directory.Exists("Log/")) Directory.CreateDirectory("Log/"); var tb = new TextBoxStreamWriter(tbConsole, cout); Console.SetOut(tb); Console.WriteLine("Running CommandBlockJS"); Thread.Sleep(1000); string world = cbWorldFolder.Text; IntVector3 pos = new IntVector3(); int.TryParse(tbPosX.Text, out pos.x); int.TryParse(tbPosY.Text, out pos.y); int.TryParse(tbPosZ.Text, out pos.z); var js = new CommandBlocksJS.Cmd.JsScriptExecutor(); try { js.Run("core.js", tbFileName.Text, world, pos, IsSchematic.IsChecked == true); Console.WriteLine("Generation finished successfully"); tb.Save(); if (cbClose.IsChecked == true) Close(); } catch (Exception e) { Console.WriteLine(e); Console.WriteLine("Generation failed"); tb.Save(); } }