diff --git a/src/BizHawk.Client.Common/lua/LuaFileList.cs b/src/BizHawk.Client.Common/lua/LuaFileList.cs index c907901320..b78458a8bc 100644 --- a/src/BizHawk.Client.Common/lua/LuaFileList.cs +++ b/src/BizHawk.Client.Common/lua/LuaFileList.cs @@ -69,7 +69,7 @@ namespace BizHawk.Client.Common return base.RemoveAll(match); } - public bool LoadLuaSession(string path) + public bool LoadLuaSession(string path, bool disableOnLoad) { var file = new FileInfo(path); if (file.Exists) @@ -95,7 +95,7 @@ namespace BizHawk.Client.Common Add(new LuaFile(scriptPath) { - State = !Global.Config.DisableLuaScriptsOnLoad && line.Substring(0, 1) == "1" + State = !disableOnLoad && line.Substring(0, 1) == "1" ? LuaFile.RunState.Running : LuaFile.RunState.Disabled }); diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index 4e7d34abde..a33c0bd213 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -59,6 +59,8 @@ namespace BizHawk.Client.EmuHawk public bool ToggleAllIfNoneSelected { get; set; } = true; public int SplitDistance { get; set; } + + public bool DisableLuaScriptsOnLoad { get; set; } } [ConfigPersist] @@ -511,7 +513,7 @@ namespace BizHawk.Client.EmuHawk public bool LoadLuaSession(string path) { - var result = LuaImp.ScriptList.LoadLuaSession(path); + var result = LuaImp.ScriptList.LoadLuaSession(path, Settings.DisableLuaScriptsOnLoad); RunLuaScripts(); UpdateDialog(); @@ -664,7 +666,7 @@ namespace BizHawk.Client.EmuHawk if (load) { - if (!LuaImp.ScriptList.LoadLuaSession(path)) + if (!LuaImp.ScriptList.LoadLuaSession(path, Settings.DisableLuaScriptsOnLoad)) { Config.RecentLuaSession.HandleLoadError(path); } @@ -770,7 +772,7 @@ namespace BizHawk.Client.EmuHawk var result = ofd.ShowHawkDialog(); if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(ofd.FileName)) { - LuaImp.ScriptList.LoadLuaSession(ofd.FileName); + LuaImp.ScriptList.LoadLuaSession(ofd.FileName, Settings.DisableLuaScriptsOnLoad); RunLuaScripts(); UpdateDialog(); LuaImp.ScriptList.Changes = false; @@ -1301,7 +1303,7 @@ namespace BizHawk.Client.EmuHawk } else if (Path.GetExtension(path)?.ToLower() == ".luases") { - LuaImp.ScriptList.LoadLuaSession(path); + LuaImp.ScriptList.LoadLuaSession(path, Settings.DisableLuaScriptsOnLoad); RunLuaScripts(); UpdateDialog(); LuaImp.ScriptList.Changes = false;