Module:Utility

From IdleOn MMO Wiki
Revision as of 18:26, 28 March 2024 by Kiokurashi (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Utility/doc

local util = {}
-- Strings
-- Format with tooltip text, then text to show on page.
util.tooltipstruct = [[<span class="simple-tooltip simple-tooltip-inline tooltipstered" data-simple-tooltip="%s">%s</span>]]


-- Functions
function util.explode(list, delimiter)
    if delimiter == nil then
		delimiter = "%s"
	end
	local t = {}
	for str in string.gmatch(list, "([^" .. delimiter .. "]+)") do
		table.insert(t, util.trimwhitespaces(str))
	end
	return t
end

function util.trimwhitespaces(s)
   return s:match( "^%s*(.-)%s*$" )
end

return util