From 2d939184694fd0f0046d6b2dafc219eccd1fccc0 Mon Sep 17 00:00:00 2001 From: Curtis Shmyr Date: Tue, 5 Aug 2014 22:36:42 -0600 Subject: [PATCH 1/2] Log reason why a Lua script fails to parse --- lua/scriptwrapper.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/scriptwrapper.lua b/lua/scriptwrapper.lua index 1603dd06c2..1f2c8211bf 100644 --- a/lua/scriptwrapper.lua +++ b/lua/scriptwrapper.lua @@ -31,9 +31,9 @@ Tick = function() end ExecuteSandboxedScript = function(file, contents) - local script = loadstring(contents, file) + local script, err = loadstring(contents, file) if (script == nil) then - FatalError("Error parsing " .. file) + FatalError("Error parsing " .. file .. ". Reason: " .. err) else TryRunSandboxed(script) end From b572c9b5eb0dc16251e12d2dc0dfc702aa28457a Mon Sep 17 00:00:00 2001 From: Curtis Shmyr Date: Tue, 5 Aug 2014 22:37:00 -0600 Subject: [PATCH 2/2] Add an ingame message if a Lua FatalError call occurs --- OpenRA.Game/Scripting/ScriptContext.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenRA.Game/Scripting/ScriptContext.cs b/OpenRA.Game/Scripting/ScriptContext.cs index 0711ab3396..b947f2237f 100644 --- a/OpenRA.Game/Scripting/ScriptContext.cs +++ b/OpenRA.Game/Scripting/ScriptContext.cs @@ -10,6 +10,7 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.IO; using System.Linq; using System.Reflection; @@ -162,6 +163,7 @@ namespace OpenRA.Scripting public void FatalError(string message) { Console.WriteLine("Fatal Lua Error: {0}", message); + Game.AddChatLine(Color.White, "Fatal Lua Error", message); error = true; }