Added some missing math functions from lua
This commit is contained in:
@@ -4,6 +4,7 @@ local AddCallMetaTable = LuaSetup.LuaUserData.AddCallMetaTable
|
|||||||
local CreateStatic = LuaSetup.LuaUserData.CreateStatic
|
local CreateStatic = LuaSetup.LuaUserData.CreateStatic
|
||||||
local CreateEnum = LuaSetup.LuaUserData.CreateEnumTable
|
local CreateEnum = LuaSetup.LuaUserData.CreateEnumTable
|
||||||
|
|
||||||
|
require("DefaultLib/Utils/Math")
|
||||||
require("DefaultLib/Utils/SteamApi")
|
require("DefaultLib/Utils/SteamApi")
|
||||||
|
|
||||||
defaultLib["SByte"] = CreateStatic("Barotrauma.LuaSByte", true)
|
defaultLib["SByte"] = CreateStatic("Barotrauma.LuaSByte", true)
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
math.lerp = function (a, b, t)
|
||||||
|
return a * (1 - t) + b * t
|
||||||
|
end
|
||||||
|
|
||||||
|
math.clamp = function (value, min, max)
|
||||||
|
return math.max(min, math.min(max, value))
|
||||||
|
end
|
||||||
|
|
||||||
|
math.round = function (value, decimals)
|
||||||
|
decimals = decimals or 0
|
||||||
|
local mult = 10 ^ decimals
|
||||||
|
return math.floor(value * mult + 0.5) / mult
|
||||||
|
end
|
||||||
|
|
||||||
|
math.sign = function (value)
|
||||||
|
return value >= 0 and 1 or -1
|
||||||
|
end
|
||||||
|
|
||||||
|
math.remap = function (value, inMin, inMax, outMin, outMax)
|
||||||
|
return outMin + (outMax - outMin) * ((value - inMin) / (inMax - inMin))
|
||||||
|
end
|
||||||
@@ -4,8 +4,8 @@ local RegisterBarotrauma = LuaSetup.LuaUserData.RegisterTypeBarotrauma
|
|||||||
Register("System.TimeSpan")
|
Register("System.TimeSpan")
|
||||||
Register("System.Exception")
|
Register("System.Exception")
|
||||||
|
|
||||||
RegisterBarotrauma("Barotrauma.Success`2[[Barotrauma.ContentPackage],[System.Exception]]")
|
RegisterBarotrauma("Success`2[[Barotrauma.ContentPackage],[System.Exception]]")
|
||||||
RegisterBarotrauma("Barotrauma.Failure`2[[Barotrauma.ContentPackage],[System.Exception]]")
|
RegisterBarotrauma("Failure`2[[Barotrauma.ContentPackage],[System.Exception]]")
|
||||||
|
|
||||||
RegisterBarotrauma("LuaSByte")
|
RegisterBarotrauma("LuaSByte")
|
||||||
RegisterBarotrauma("LuaByte")
|
RegisterBarotrauma("LuaByte")
|
||||||
|
|||||||
Reference in New Issue
Block a user