Fortnite Esports Wiki

Power Rankings of Brazil and Oceania are not yet updated to the last season, we are doing our best to update them before the start of the new competitive season. Please be patient.

READ MORE

Fortnite Esports Wiki
Advertisement
Fortnite Esports Wiki

To edit the documentation or categories for this module, click here.


-- util
local p = {}

function p.nowrap(text)
	return '<span style="white-space:nowrap;">' .. text .. '</span>'
end

function p.escape(link)
	link = link or ''
	-- because of gsub not letting you have - unescaped
	link = string.gsub(link,'%-','%%%-')
	link = string.gsub(link,'%(','%%%(')
	link = string.gsub(link,'%)','%%%)')
	link = string.gsub(link,'%+','%%%+')
	return link
end

function p.serializeNumber(N)
	local chr = tostring(N):sub(-1)
	local lookup = { ['1'] = 'st', ['2'] = 'nd', ['3'] = 'rd' }
	return N .. (lookup[chr] or 'th')
end

-- given a table of images, links, and sizes, return a table of formatted images
function p.linkedImages(images, links, sizes)
	local tbl = {}
	for k, v in ipairs(images) do
		tbl[k] = string.format('[[File:%s|link=%s|%s]]',
			v,
			links and links[k] or '',
			sizes and sizes[k] or ''
		)
	end
	return tbl
end

function p.nextLetter(char)
	return string.char(char:byte() + 1)
end

function p.globalIndex(name, f)
	if not f then
		f = mw.getCurrentFrame()
	end
	local n = (tonumber(f:callParserFunction('#var','luaGlobalIndex' .. name) or 0) or 0) + 1
	f:callParserFunction('#vardefine:luaGlobalIndex' .. name, n)
	return n
end
	

return p
Advertisement