コード例 #1
0
        /// <summary>
        ///     Loads mod's scripting features.
        ///     Returns true if successful.
        /// </summary>
        public static bool LoadEngine(bool verbose = false)
        {
            if (PythonEnvironment.LoadPythonAssembly())
            {
                try
                {
                    PythonEnvironment.InitializeEngine();
                    CreateScriptingEnvironment();
                    _component = Mod.Controller.AddComponent <ScriptComponent>();

                    if (verbose)
                    {
                        ModConsole.AddMessage(LogType.Log, $"[LenchScripterMod]: {Python.Execute("sys.version")}");
                    }

                    Mod.LoadedScripter = true;
                }
                catch (Exception e)
                {
                    if (verbose)
                    {
                        ModConsole.AddMessage(LogType.Log, "[LenchScripterMod]: Error while initializing python engine:", e.ToString());
                    }
                    Mod.LoadedScripter = false;
                }
            }
            else
            {
                Mod.LoadedScripter = false;
            }
            return(Mod.LoadedScripter);
        }