Module:Quantity box

From RuneRealm Wiki
Jump to navigation Jump to search
Module documentation
This documentation is transcluded from Module:Quantity box/doc. [edit] [history] [purge]
Module:Quantity box's function main is invoked by Template:Quantity box.
Module:Quantity box requires Module:Addcommas.
Module:Quantity box is required by Module:Sandbox/User:Riblet15/Skill info.
Module:Quantity box is required by Module:Skill info.

This module is a helper module to be used by other modules; it may not designed to be invoked directly. See RuneScape:Lua/Helper modules for a full list and more information. For a full list of modules using this helper click here

FunctionTypeUse
_main(quantity)StringTakes inputs and gives outputs like Template:Quantity box. See the template documentation for more info.

local p = {}
local commas = require('Module:Addcommas')._add

function p._main(arg, init)
	if arg == '' or arg == nil then
		return ''
	end
	-- convert init to string if it is a number, or set to '1' if it is not a (string of a) number
	init = tonumber(init) and tostring(init) or '1'
	if tonumber(arg) then
		return string.format('<span class="infobox-quantity" data-val-each="%s" data-value="%s"><span class="infobox-quantity-replace">%s</span> xp</span>', arg, init, commas(arg))
	else
		return arg
	end
end

function p.main(frame)
	local args = frame:getParent().args
	return p._main(mw.text.trim(args[1], args[2]))
end

return p