diff --git a/lua/wire/wireshared.lua b/lua/wire/wireshared.lua index 106989c7aa..a763537754 100644 --- a/lua/wire/wireshared.lua +++ b/lua/wire/wireshared.lua @@ -942,11 +942,9 @@ local minx, miny, minz = -16384, -16384, -16384 local maxx, maxy, maxz = 16384, 16384, 16384 local clamp = math.Clamp function WireLib.clampPos(pos) - pos = Vector(pos) - pos.x = clamp(pos.x, minx, maxx) - pos.y = clamp(pos.y, miny, maxy) - pos.z = clamp(pos.z, minz, maxz) - return pos + local x, y, z = pos:Unpack() + + return Vector(clamp(x, minx, maxx), clamp(y, miny, maxy), clamp(z, minz, maxz)) end function WireLib.setPos(ent, pos) @@ -1014,10 +1012,12 @@ end) -- Nan never equals itself, so if the value doesn't equal itself replace it with 0. function WireLib.clampForce( v ) + local x, y, z = v:Unpack() + return Vector( - v[1] == v[1] and math.Clamp( v[1], min_force, max_force ) or 0, - v[2] == v[2] and math.Clamp( v[2], min_force, max_force ) or 0, - v[3] == v[3] and math.Clamp( v[3], min_force, max_force ) or 0 + clamp( x, min_force, max_force ), + clamp( y, min_force, max_force ), + clamp( z, min_force, max_force ) ) end @@ -1330,4 +1330,4 @@ local typeIDToStringTable = { -- Silly function to make printouts more userfriendly. function WireLib.typeIDToString(typeID) return typeIDToStringTable[typeID] or "unregistered type" -end \ No newline at end of file +end