Skip to content

Create s_util.lua #624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions [gamemodes]/[race]/[addons]/race_nos/s_util.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

g_Root = getRootElement()
g_ResRoot = getResourceRootElement(getThisResource())

function table.size(tab)
local size = 0
for i,v in pairs(tab) do
size = size + 1
end
return size
end

function string:split(sep)
if #self == 0 then
return {}
end
sep = sep or ' '
local result = {}
local from = 1
local to
repeat
to = self:find(sep, from, true) or (#self + 1)
result[#result+1] = self:sub(from, to - 1)
from = to + 1
until from == #self + 2
return result
end


function toboolean(var)
if type(var) == "string" then
return (var == "true")
end
if type(var) == "number" then
return (var == 1)
end
return not not var
end