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

View File

@@ -53,7 +53,14 @@ luaUserData.AddCallMetaTable = function (userdata)
error("userdata was nil.", 2)
end
return userdata.__new(...)
local success, result = pcall(userdata.__new, ...)
if not success then
error(result, 2)
end
return result
end
})
end

View File

@@ -271,6 +271,7 @@ namespace Barotrauma
Lua.Options.DebugPrint = PrintMessage;
Lua.Options.ScriptLoader = LuaScriptLoader;
Lua.Options.CheckThreadAccess = false;
Script.GlobalOptions.ShouldPCallCatchException = (Exception ex) => { return true; };
CsScript = new CsScriptRunner(this);
require = new LuaRequire(Lua);