Update Moonsharp for the new pcall exception handling

This commit is contained in:
EvilFactory
2022-10-29 20:30:02 -03:00
parent b77dde156b
commit e7d98dc887
3 changed files with 10 additions and 2 deletions
@@ -53,7 +53,14 @@ luaUserData.AddCallMetaTable = function (userdata)
error("userdata was nil.", 2) error("userdata was nil.", 2)
end end
return userdata.__new(...) local success, result = pcall(userdata.__new, ...)
if not success then
error(result, 2)
end
return result
end end
}) })
end end
@@ -271,6 +271,7 @@ namespace Barotrauma
Lua.Options.DebugPrint = PrintMessage; Lua.Options.DebugPrint = PrintMessage;
Lua.Options.ScriptLoader = LuaScriptLoader; Lua.Options.ScriptLoader = LuaScriptLoader;
Lua.Options.CheckThreadAccess = false; Lua.Options.CheckThreadAccess = false;
Script.GlobalOptions.ShouldPCallCatchException = (Exception ex) => { return true; };
CsScript = new CsScriptRunner(this); CsScript = new CsScriptRunner(this);
require = new LuaRequire(Lua); require = new LuaRequire(Lua);