/// <summary> /// Initializes Python environment and compiles code. /// Sets Running to true if successfull. /// </summary> protected override void Initialise() { if (!PythonEnvironment.Loaded) { return; } init = null; update = null; initialised = false; if (!Running && !Game.IsSimulating) { return; } Error = null; Running = false; if (GlobalScope) { if (PythonEnvironment.ScripterEnvironment == null) { InitGlobalScope(); } python = PythonEnvironment.ScripterEnvironment; } else { python = new PythonEnvironment(); } try { // Attempts to compile initialisation and update code. init = python.Compile(InitialisationCode); update = python.Compile(UpdateCode); // Executes initialisation code and checks it's scope for linked axes. init.Invoke(); LinkAxes(); } catch (Exception e) { if (e.InnerException != null) { e = e.InnerException; } Error = PythonEnvironment.FormatException(e); return; } Running = true; initialised = true; }