34 lines
832 B
Lua
34 lines
832 B
Lua
function string:split(sep)
|
|
local sep, fields = sep or ":", {}
|
|
local pattern = string.format("([^%s]+)", sep)
|
|
self:gsub(pattern, function(c) fields[#fields+1] = c end)
|
|
return fields
|
|
end
|
|
|
|
function prefixZeroes(inputString, lengthDesired)
|
|
|
|
local length = string.len(inputString)
|
|
|
|
while length < lengthDesired do
|
|
inputString = "0" .. inputString
|
|
length = length + 1
|
|
end
|
|
|
|
return inputString
|
|
end
|
|
|
|
function doesModuleExist(name)
|
|
if package.loaded[name] then
|
|
return true
|
|
else
|
|
for _, searcher in ipairs(package.searchers or package.loaders) do
|
|
local loader = searcher(name)
|
|
if type(loader) == "function" then
|
|
package.preload[name] = loader
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
end
|