Changes

Created page with "local p = {} -- Module for random library functions for lua because lua sucks. Written by -- Remi_Scarlet -- I fucking hate lua. -- takes a string and returns string with f..."
local p = {}

-- Module for random library functions for lua because lua sucks. Written by
-- Remi_Scarlet
-- I fucking hate lua.


-- takes a string and returns string with first letter capitalized
function p.capitalize(str)
return (str:gsub("^%l", string.upper))
end

-- returns a string representation of a table.
-- cannot do recursive tables. Eg, only single dimensional tables will work
-- should a multi-dimensional table be given, it will simply put "table" as the value
function p.dictConcat(dict,sep)
if sep == nil then sep = " | " end
local final = ""
for k,v in pairs(dict) do
if k ~= nil then
if v ~= nil then
final = final .. k .. "=" .. tostring(v) .. sep
else
final = final .. k .. "= nil" .. sep
end
else
if v ~= nil then
final = final .. tostring(v) .. sep
else
final = final .. "nil" .. sep
end
end
end
return final
end


-- checks if data is in the array as a key
function p.valid(data, array)
local valid = {}
if array ~= nil then
for i = 1, #array do
valid[array[i]] = true
end
if valid[data] then
return true
else
return false
end
end
end

return p
2,922

edits