Módulo:Número de estrelas

Fonte: Enciclopédia de conhecimento da Igreja de Deus
Saltar para a navegação Saltar para a pesquisa

A documentação para este módulo pode ser criada na página Módulo:Número de estrelas/doc

local p = {}
function p._starnumber(num, maxnum) -- num of stats / maximal number of stars possible (shows grey stars for the difference)
				if not num then
								return nil
				end
				if not tonumber(num) then
								return num .. '(?)' -- error handling ?
				end
				num = tonumber(num)
				local maxnum = tonumber(maxnum) or num
				local starsize = '11px'
				if maxnum > 6 then
								starsize = '7px'
				end
				
				local str = ''
				local images = {
								full = 'Star full.svg',
								half = 'Star half.svg',
								empty = 'Star empty.svg'
				}
				local function addstar(startype)
								str = str .. '[[File:' .. images[startype] .. '|' .. starsize .. ']]'
				end
				for i = 1, math.floor(num) do
								addstar('full')
				end
				
				if num > math.floor(num) then -- meia estrela
								addstar('half')
				end
				
				for i = 1, (maxnum - math.ceil(num)) do
								addstar('empty')
				end
				
				return  '<span style="white-space:nowrap">' .. str  .. '</span>'
end
function p.starnumber(frame)
				return p._starnumber(frame.args[1], frame.args[2])
end
return p