Racelogic, Mustang, Porsche, etc.

This commit is contained in:
Nikita Kruglickiy
2021-06-06 18:34:44 +06:00
parent 1aafe32376
commit 9ff9b08a42
16 changed files with 776 additions and 133 deletions

View File

@@ -1,5 +1,4 @@
-- @name koptilnya/libs/utils
function checkVarClass(var, class, message)
if type(var) ~= "table" or var["class"] == nil or not var:isInstanceOf(class) then
throw(message == nil and "Wrong variable class." or message, 1, true)
@@ -24,3 +23,48 @@ function rotateAround(entity, pivot, angles)
pos = pos + (pivot - entity:localToWorld(localPivotPos))
entity:setPos(pos)
end
function tobase(number, base)
local ret = ""
if base < 2 or base > 36 or number == 0 then
return "0"
end
if base == 10 then
return tostring(number)
end
local chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
local loops = 0
while number > 0 do
loops = loops + 1
number, d = math.floor(number / base), (number % base) + 1
ret = string.sub(chars, d, d) .. ret
if (loops > 32000) then
break
end
end
return ret
end
function bytesToHex(bytes)
local hex = "0x"
for _, v in pairs(bytes) do
hex = hex .. bit.tohex(v, 2)
end
return hex
end
function byteTable(str, start, length)
local result = {}
for i = 1, length do
result[i] = string.byte(str, i + start - 1)
end
return result
end