From 48a6686f3113d7bed2e93bd7a28fa4e5e616a6e0 Mon Sep 17 00:00:00 2001 From: scepheo Date: Sun, 8 Feb 2015 23:47:15 +0000 Subject: [PATCH] Lua Console: Command window gives slightly more sensible output now. --- BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index 5b6abd1f32..56d0eb6ea8 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -1133,28 +1133,29 @@ namespace BizHawk.Client.EmuHawk if (e.KeyCode == Keys.Enter) { string consoleBeforeCall = OutputBox.Text; + // TODO: Maybe make these try-catches more general if (InputBox.Text != "") { try { - LuaImp.ExecuteString(InputBox.Text); - - // TODO: This isn't exactly optimal - if (OutputBox.Text == consoleBeforeCall) - ConsoleLog("Command successfully executed"); + LuaImp.ExecuteString(string.Format("console.log({0})", InputBox.Text)); } - catch (LuaScriptException ex) + catch { try { - LuaImp.ExecuteString(string.Format("console.log({0})", InputBox.Text)); + LuaImp.ExecuteString(InputBox.Text); + + if (OutputBox.Text == consoleBeforeCall) + ConsoleLog("Command successfully executed"); } - catch + catch (LuaScriptException ex) { ConsoleLog(ex.ToString()); } } + _consoleCommandHistory.Insert(0, InputBox.Text); _consoleCommandHistoryIndex = -1; InputBox.Clear();