Module:Util

From Artifact Wiki
Jump to: navigation, search

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

p = {}

-- Fix output formatting (remove all line breaks)
function p.fixOut(s)
	local out, _ = string.gsub(s, "/n", "")
	return out
end

function p.fixLink(s)
	local out, _ = string.gsub(s, " ", "_")
	return out
end

function p.isempty(s)
	return s == nil or s == ''
end

function p.floor(d)
	return math.floor(d)
end

function p.round(d)
	local numDecimalPlaces = 2
	local mult = 10^(numDecimalPlaces or 0)
	return math.floor(d * mult + 0.5) / mult
end

function p.getBaseURL()
	return "https://artifactwiki.com/wiki/"
end

function p.getRootURL()
	return "https://artifactwiki.com/"
end

return p