public void LoadLuaFile(string path) { var processedPath = PathManager.TryMakeRelative(path); string pathToLoad = Path.IsPathRooted(processedPath) ? processedPath : PathManager.MakeProgramRelativePath(processedPath); //JUNIPIER SQUATCHBOX COMPLEX if (LuaAlreadyInSession(processedPath) == false) { var luaFile = new LuaFile(string.Empty, processedPath); _luaList.Add(luaFile); LuaListView.ItemCount = _luaList.Count; Global.Config.RecentLua.Add(processedPath); if (!Global.Config.DisableLuaScriptsOnLoad) { try { LuaSandbox.Sandbox(null, () => { luaFile.Thread = LuaImp.SpawnCoroutine(pathToLoad); LuaSandbox.CreateSandbox(luaFile.Thread, Path.GetDirectoryName(pathToLoad)); luaFile.State = LuaFile.RunState.Running; }, () => { luaFile.State = LuaFile.RunState.Disabled; }); } catch (Exception e) { MessageBox.Show(e.ToString()); } } else { luaFile.State = LuaFile.RunState.Disabled; } if (Global.Config.LuaReloadOnScriptFileChange) { CreateFileWatcher(processedPath); } //luaFile.Paused = false; } else { foreach (var file in _luaList.Where(file => processedPath == file.Path && file.Enabled == false && !Global.Config.DisableLuaScriptsOnLoad)) { file.Toggle(); break; } RunLuaScripts(); } UpdateDialog(); }
public void LoadLuaFile(string path) { var processedPath = PathManager.TryMakeRelative(path); if (LuaAlreadyInSession(processedPath) == false) { var luaFile = new LuaFile(string.Empty, processedPath); _luaList.Add(luaFile); LuaListView.ItemCount = _luaList.Count; Global.Config.RecentLua.Add(processedPath); if (!Global.Config.DisableLuaScriptsOnLoad) { try { luaFile.Thread = LuaImp.SpawnCoroutine(processedPath); luaFile.Enabled = true; } catch (Exception e) { if (e.GetType() == typeof(LuaInterface.LuaScriptException)) { luaFile.Enabled = false; ConsoleLog(e.Message); } else { MessageBox.Show(e.ToString()); } } } else { luaFile.Enabled = false; } luaFile.Paused = false; } else { foreach (var file in _luaList.Where(file => processedPath == file.Path && file.Enabled == false && !Global.Config.DisableLuaScriptsOnLoad)) { file.Toggle(); break; } RunLuaScripts(); } UpdateDialog(); }
public void LoadLuaFile(string path) { var processedPath = PathManager.TryMakeRelative(path); if (LuaAlreadyInSession(processedPath) == false) { var luaFile = new LuaFile(string.Empty, processedPath); _luaList.Add(luaFile); LuaListView.ItemCount = _luaList.Count; Global.Config.RecentLua.Add(processedPath); if (!Global.Config.DisableLuaScriptsOnLoad) { try { LuaSandbox.Sandbox(() => { luaFile.Thread = LuaImp.SpawnCoroutine(processedPath); luaFile.State = LuaFile.RunState.Running; }, () => { luaFile.State = LuaFile.RunState.Disabled; }); } catch (Exception e) { MessageBox.Show(e.ToString()); } } else { luaFile.State = LuaFile.RunState.Disabled; } //luaFile.Paused = false; } else { foreach (var file in _luaList.Where(file => processedPath == file.Path && file.Enabled == false && !Global.Config.DisableLuaScriptsOnLoad)) { file.Toggle(); break; } RunLuaScripts(); } UpdateDialog(); }