update
This commit is contained in:
24
utils.lua
24
utils.lua
@@ -12,9 +12,33 @@ function get_args_kv()
|
||||
return { keys, values }
|
||||
end
|
||||
|
||||
function string:split(sep)
|
||||
if sep == nil then
|
||||
sep = "%s"
|
||||
end
|
||||
|
||||
local t={}
|
||||
|
||||
for str in string.gmatch(self, "([^"..sep.."]+)") do
|
||||
table.insert(t, str)
|
||||
end
|
||||
|
||||
return t
|
||||
end
|
||||
|
||||
function round(x, n)
|
||||
local n = math.pow(10, n or 0)
|
||||
local x = x * n
|
||||
if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end
|
||||
return x / n
|
||||
end
|
||||
|
||||
function table:has_value(val)
|
||||
for index, value in ipairs(self) do
|
||||
if value == val then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user