From 33ca14a344c706c0669d982d7c7bc768daa7686e Mon Sep 17 00:00:00 2001 From: kylethomson Date: Mon, 23 Jan 2012 01:10:56 +0000 Subject: [PATCH] Getting closer. Now catches a .NET exception in user code. --- BizHawk.MultiClient/LuaImplementation.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/BizHawk.MultiClient/LuaImplementation.cs b/BizHawk.MultiClient/LuaImplementation.cs index 0a04e36ab8..eae420a88a 100644 --- a/BizHawk.MultiClient/LuaImplementation.cs +++ b/BizHawk.MultiClient/LuaImplementation.cs @@ -13,7 +13,7 @@ namespace BizHawk.MultiClient { public class LuaImplementation { - Lua lua = new Lua(); + Lua lua = new Lua(); LuaConsole Caller; public String LuaLibraryList = ""; public EventWaitHandle LuaWait; @@ -23,9 +23,13 @@ namespace BizHawk.MultiClient public LuaImplementation(LuaConsole passed) { - EventWaitHandle LuaWait = new AutoResetEvent(false); + LuaWait = new AutoResetEvent(false); LuaLibraryList = ""; Caller = passed.get(); + LuaRegister(lua); + } + public void LuaRegister(Lua lua) + { lua.RegisterFunction("print", this, this.GetType().GetMethod("print")); //Register libraries @@ -82,7 +86,14 @@ namespace BizHawk.MultiClient { string F = File.ToString(); isRunning = true; - lua.DoFile(F); + try + { + lua.DoFile(F); + } + catch (Exception e) + { + MessageBox.Show("Exception caught. " + e.ToString()); + } isRunning = false; LuaWait.Set(); }