LuaConsole: Actually stop and restart script upon tool restart.

This commit is contained in:
scepheo 2015-01-29 14:50:09 +00:00
parent 6f2488aa57
commit 860227ee66
1 changed files with 38 additions and 0 deletions

View File

@ -107,9 +107,47 @@ namespace BizHawk.Client.EmuHawk
{
LuaImp.GuiLibrary.DrawFinish();
}
var runningScripts = _luaList.Where(f => f.Enabled).ToList();
foreach (var file in runningScripts)
{
LuaImp.CallExitEvent(file.Thread);
var functions = LuaImp.RegisteredFunctions.Where(x => x.Lua == file.Thread).ToList();
foreach (var function in functions)
LuaImp.RegisteredFunctions.Remove(function);
UpdateRegisteredFunctionsDialog();
file.Stop();
}
LuaImp = new EmuLuaLibrary(this);
InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => a.Library + "." + a.Name).ToArray());
foreach (var file in runningScripts)
{
try
{
file.Thread = LuaImp.SpawnCoroutine(file.Path);
file.Enabled = true;
}
catch (Exception ex)
{
if (ex is LuaScriptException)
{
file.Enabled = false;
ConsoleLog(ex.Message);
}
else
{
MessageBox.Show(ex.ToString());
}
}
}
UpdateDialog();
}