Módulo:Infobox minério
Documentação do módulo
Esta documentação é transcluída de Módulo:Infobox minério/doc. [editar] [atualizar]
Módulo:Infobox minério's a função main é invocada por Predefinição:Infobox minério.
Módulo:Infobox minério requer Módulo:MercadoLite.
Módulo:Infobox minério requer Módulo:Moedas.
Módulo:Infobox minério carrega dados de Módulo:Minérios.
-- <nowiki>
local gemw = require('Módulo:MercadoLite')
local p = {}
local data = mw.loadData('Módulo:Minérios')
local coins = require('Módulo:Moedas')
function plink(name, opts)
local file = name.. '.png'
local link = name
local text = name
if type(opts) == 'table' then
if opts.txt then
text = opts.txt
end
if opts.img then
file = opts.img
end
end
if text ~= '' then
text = string.format(' [[%s|%s]]', link,text)
end
return string.format('[[Ficheiro:%s|link=%s|frameless|35px]]%s', file, link, text)
end
function plinkp(name, img)
return plink(name, {img = img, txt = ''})
end
function getn(a)
local max = 0
for i = 1,1000,1 do
if a[i] ~= nil then max = i
else break end
end
return max
end
function p.main(frame)
local args = frame:getParent().args
local name = args[1]
local type = string.lower(args[2] or 'minério')
local t = mw.html.create('table')
t:addClass('wikitable')
:css('text-align', 'center')
for index,i in ipairs(data) do
if name == i.name then
local test = i
t:tag('tr')
if type == 'minério' then
t:tag('th') :wikitext(plink((i.output or name), { img = (i.img or i.output or name)..'.png'})) :attr('colspan', 6) :done()
elseif type == 'rocha' then
t:tag('th') :wikitext(plink((i.source1 or i.source or (name..' rocha')), { img = (i.srcimg or i.source1 or i.source or (name..' rocha'))..'.png'} )) :attr('colspan', 6) :done()
else return 'Você deve escolher "rocha" ou "minério" como um tipo.'
end
if i.core == 1 then
local minVarrockArmourLevel = 0
for x = 1,4,1 do
if (i.varrock[x] == 1 and minVarrockArmourLevel == 0) then minVarrockArmourLevel = x
end end
local crit,rck,geode_chance_one,geode_chance_two,dbl_chance
if i.crit[2] ~= nil then crit = '[[File:Mineração ícone.png|21x21px|link=]] '..i.crit[2] else crit = '-' end
if i.rck[2] ~= nil then rck = '[[File:Mineração ícone.png|21x21px|link=]] '..i.rck[2] else rck = '-' end
if i.geode_chance_level[1] ~= nil then geode_chance_one = '[[File:Mineração ícone.png|21x21px|link=]] '..i.geode_chance_level[1] else geode_chance_one = '-' end
if i.geode_chance_level[2] ~= nil then geode_chance_two = '[[File:Mineração ícone.png|21x21px|link=]] '..i.geode_chance_level[2] else geode_chance_two = '-' end
if i.double_ore_chance[2] ~= nil then dbl_chance = '[[File:Mineração ícone.png|21x21px|link=]] '..i.double_ore_chance[2] else dbl_chance = '-' end
t:tag('tr')
:tag('th') :wikitext('[[Mineração|Nível de Mineração]]') :attr('colspan', 2) :done()
:tag('td') :wikitext('[[File:Mineração ícone.png|21x21px|link=]] '..i.level) :attr('colspan', 2) :done()
:tag('th') :wikitext('Chance de acerto crítico') :attr('colspan', 2) :done()
:tag('tr')
if type == 'minério' then
t:tag('th') :wikitext('Fonte') :attr('colspan', 2) :done()
if i.source == nil then
t:tag('td') :wikitext('[['..i.name..' rocks]]') :attr('colspan', 2) :done()
else
t:tag('td') :wikitext('[['..i.source..']]') :attr('colspan', 2) :done()
end
elseif type == 'rocha' then
t:tag('th') :wikitext('Produto') :attr('colspan', 2) :done()
if i.output == nil then
t:tag('td') :wikitext('[['..name..']]') :attr('colspan', 2) :done()
else
t:tag('td') :wikitext('[['..i.output..']]') :attr('colspan', 2) :css('text-align', 'left') :done()
end
end
t:tag('th') :wikitext('10%') :done()
:tag('th') :wikitext('15%') :done()
:tag('tr')
:tag('th') :wikitext('Principal') :attr('colspan', 2) :done()
:tag('td') :wikitext('[[File:Sim.svg|20px|link=]]') :attr('colspan', 2) :done()
:tag('td') :wikitext('[[File:Mineração ícone.png|21x21px|link=]] '..(i.crit[1]))
:tag('td') :wikitext(crit)
:tag('tr')
:tag('th') :wikitext('Espírito da pedra') :attr('colspan', 2) :done()
:tag('td') :wikitext(plink('Espírito da pedra de '..i.spirit, { txt = i.spirit})) :attr('colspan', 2) :done()
:tag('th') :wikitext('Multiplicador de oportunirrochas') :attr('colspan', 2) :done()
:tag('tr')
:tag('th') :wikitext('Geodo') :attr('colspan', 2) :done()
:tag('td') :wikitext(plink('Geodo '..i.geode, { txt = i.geode})) :attr('colspan', 2) :done()
:tag('th') :wikitext('x5')
:tag('th') :wikitext('x6')
:tag('tr')
:tag('th') :wikitext('Estatísticas da rocha') :attr('colspan', 4)
:tag('td') :wikitext('[[File:Mineração ícone.png|21x21px|link=]] '..(i.rck[1]))
:tag('td') :wikitext(rck)
:tag('tr')
:tag('th') :wikitext('Pontos de vida') :attr('colspan', 2)
:tag('td') :wikitext(i.hp) :attr('colspan', 2)
:tag('th') :wikitext('Chance de minério duplo') :attr('colspan', 2)
:tag('tr')
:tag('th') :wikitext('Rigidez') :attr('colspan', 2)
:tag('td') :wikitext(i.hardness) :attr('colspan', 2)
:tag('th') :wikitext('5%')
:tag('th') :wikitext('10%')
:tag('tr')
:tag('th') :wikitext('Multiplicador') :attr('colspan', 2)
:tag('td') :wikitext(i.mult) :attr('colspan', 2)
:tag('td') :wikitext('[[File:Mineração ícone.png|21x21px|link=]] '..(i.double_ore_chance[1]))
:tag('td') :wikitext(dbl_chance)
:tag('tr')
:tag('th') :wikitext('Minério base') :attr('colspan', 2)
:tag('td') :wikitext(i.ore) :attr('colspan', 2)
:tag('th') :wikitext('Chance de geodo') :attr('colspan', 2)
:tag('tr')
:tag('th') :wikitext('Chance de bônus da Armadura de Varrock') :attr('colspan', 4)
:tag('th') :wikitext('10%')
:tag('th') :wikitext('15%')
:tag('tr')
if minVarrockArmourLevel > 0 then
t:tag('td') :wikitext(plinkp('Armadura de Varrock ' .. minVarrockArmourLevel)) :attr('colspan', 2)
:tag('td') :wikitext((5-minVarrockArmourLevel) .. '%') :attr('colspan', 2)
else
t:tag('td') :wikitext('Sem bônus') :attr('colspan', 4)
end
t:tag('td') :wikitext(geode_chance_one)
:tag('td') :wikitext(geode_chance_two)
else
t:tag('tr')
:tag('th') :wikitext('[[Mineração|Nível de Mineração]]')
:tag('td') :wikitext('[[File:Mineração ícone.png|21x21px|link=]] '..i.level)
:tag('tr')
if type == 'minério' then
t:tag('th') :wikitext('Fonte')
if i.source ~= nil then
if getn(i.source) == 0 then
t:tag('td') :wikitext('[['..i.source..']]')
else
local sources = ''
for x = 1,getn(i.source),1 do
sources = sources..'[['..i.source[x]..']]'..'<br>'
end
t:tag('td') :wikitext(sources)
end
else
t:tag('td') :wikitext('[[Rochas com '..i.name..']]')
end
elseif type == 'rocha' then
t:tag('th') :wikitext('Produto')
if i.output ~= nil then
if getn(i.output) == 0 then
t:tag('td') :wikitext('[['..i.output..']]')
else
local outputs = ''
for x = 1,getn(i.output),1 do
outputs = outputs..plink(i.output[x])..'<br>'
end
t:tag('td') :wikitext(outputs)
end
else
t:tag('td') :wikitext('[['..name..']]')
end
end
t:tag('tr')
:tag('th') :wikitext('Principal')
:tag('td') :wikitext('[[File:Não.svg|20px|link=]]')
:tag('tr')
if i.spirit ~= nil then
t:tag('th') :wikitext('Espírito da pedra')
:tag('td') :wikitext(plink('Espírito da pedra de '..i.spirit, { txt = i.spirit}))
end
t:tag('tr')
:tag('th') :wikitext('Estatísticas') :attr('colspan', 2)
:tag('tr')
:tag('th') :wikitext('Pontos de vida')
:tag('td') :wikitext(i.hp)
:tag('tr')
:tag('th') :wikitext('Rigidez')
:tag('td') :wikitext(i.hardness)
:tag('tr')
:tag('th') :wikitext('Multiplicador')
:tag('td') :wikitext(i.mult)
:tag('tr')
:tag('th') :wikitext('Minério base')
:tag('td') :wikitext(i.ore)
end
end
end
return t
end
return p
-- </nowiki>