shitty-rp-bot/lib.lua

36 lines
680 B
Lua

function switch(t)
t.case = function (self,x)
local f=self[x] or self.default
if f then
if type(f)=="function" then
f(x,self)
else
error("case "..tostring(x).." not a function")
end
end
end
return t
end
function split(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
function string.starts(String,Start)
return string.sub(String,1,string.len(Start))==Start
end
function string.ends(String,End)
return End=='' or string.sub(String,-string.len(End))==End
end
math.randomseed(os.time())