make my eyes happier: Random is now deprecated, moved lots of code around in a way that makes more sense and better LuaUserData error handling

This commit is contained in:
Evil Factory
2022-03-17 12:47:19 -03:00
parent 6026a0246d
commit 86066282cc
11 changed files with 1414 additions and 1416 deletions
@@ -2,7 +2,7 @@
local compatibilityLib = {}
LuaUserData.AddMethod(LuaUserData.RegisterType("Barotrauma.LuaSetup+LuaUserData"), "AddCallMetaMember", function (v)
LuaUserData.AddMethod(LuaUserData.RegisterType("Barotrauma.LuaUserData"), "AddCallMetaMember", function (v)
print("AddCallMetaMember is deprecated, use debug.setmetatable instead.")
end)
@@ -10,6 +10,18 @@ compatibilityLib.CreateVector2 = Vector2.__new
compatibilityLib.CreateVector3 = Vector3.__new
compatibilityLib.CreateVector4 = Vector4.__new
local luaRandom = {}
luaRandom.Range = function (min, max)
return math.random(min, max)
end
luaRandom.RangeFloat = function (min, max)
return math.random() + math.random(min, max)
end
compatibilityLib["Random"] = luaRandom
local luaPlayer = {}
luaPlayer.GetAllCharacters = function ()