Module:Obstacles/Recommended: Difference between revisions

m
forgot the txt
m (typo)
m (forgot the txt)
 
(12 intermediate revisions by the same user not shown)
Line 8: Line 8:


local tiers = {
local tiers = {
{ tier = 1, name = 'obs1', icon = 'Agility', txt = 'I', link = 'Agility#Obstacle 1' },
{ tier = 1, name = 'obs1', icon = 'Agility', txt = 'I', link = 'Obstacle 1' },
{ tier = 2, name = 'obs2', icon = 'Agility', txt = 'II', link = 'Agility#Obstacle 2' },
{ tier = 2, name = 'obs2', icon = 'Agility', txt = 'II', link = 'Obstacle 2' },
{ tier = 3, name = 'obs3', icon = 'Agility', txt = 'III', link = 'Agility#Obstacle 3' },
{ tier = 3, name = 'obs3', icon = 'Agility', txt = 'III', link = 'Obstacle 3' },
{ tier = 4, name = 'obs4', icon = 'Agility', txt = 'IV', link = 'Agility#Obstacle 4' },
{ tier = 4, name = 'obs4', icon = 'Agility', txt = 'IV', link = 'Obstacle 4' },
{ tier = 5, name = 'obs5', icon = 'Agility', txt = 'V', link = 'Agility#Obstacle 5' },
{ tier = 5, name = 'obs5', icon = 'Agility', txt = 'V', link = 'Obstacle 5' },
{ tier = 6, name = 'obs 6', icon = 'Agility', txt = 'VI', link = 'Agility#Obstacle 6' },
{ tier = 6, name = 'obs6', icon = 'Agility', txt = 'VI', link = 'Obstacle 6' },
{ tier = 7, name = 'obs7', icon = 'Agility', txt = 'VII', link = 'Agility#Obstacle 7' },
{ tier = 7, name = 'obs7', icon = 'Agility', txt = 'VII', link = 'Obstacle 7' },
{ tier = 8, name = 'obs8', icon = 'Agility', txt = 'VIII', link = 'Agility#Obstacle 8' },
{ tier = 8, name = 'obs8', icon = 'Agility', txt = 'VIII', link = 'Obstacle 8' },
{ tier = 9, name = 'obs9', icon = 'Agility', txt = 'IX', link = 'Agility#Obstacle 9' },
{ tier = 9, name = 'obs9', icon = 'Agility', txt = 'IX', link = 'Obstacle 9' },
{ tier = 10, name = 'obs10', icon = 'Agility', txt = 'X', link = 'Agility#Obstacle 10' },
{ tier = 10, name = 'obs10', icon = 'Agility', txt = 'X', link = 'Obstacle 10' },
{ tier = 11, name = 'pillar', icon = 'Agility', txt = 'Pillar', link = 'Agility#Pillars' },
{ tier = 11, name = 'obs11', icon = 'Agility', txt = 'XI', link = 'Obstacle 11' },
{ tier = 12, name = 'obs12', icon = 'Agility', txt = 'XII', link = 'Obstacle 12' },
{ tier = 13, name = 'obs13', icon = 'Agility', txt = 'XIII', link = 'Obstacle 13' },
{ tier = 14, name = 'obs14', icon = 'Agility', txt = 'XIV', link = 'Obstacle 14' },
{ tier = 15, name = 'obs15', icon = 'Agility', txt = 'XV', link = 'Obstacle 15' },
{ tier = 98, name = 'pillar', icon = 'Agility', txt = 'Pillar', link = 'Passive Pillars' },
{ tier = 99, name = 'epillar', icon = 'Agility', txt = 'Elite Pillar', link = 'Passive Pillars' },
}
}


function p.main(frame)
function p.main(frame)
local args = frame:getParent().args
local args = frame:getParent().args
-- local args = frame.args
-- Dynamic colspan and N/A generation value
-- Dynamic colspan and N/A generation value
local greatest_row_size = 0
local greatest_row_size = 0
Line 28: Line 35:
local number_of_possible_choices = 6
local number_of_possible_choices = 6
-- Have to sort this table or else the order is messed up when you use it
-- Have to sort this table or else the order is messed up when you use it
table.sort(tiers, function(a, b) return a.placement < b.placement end)
table.sort(tiers, function(a, b) return a.tier < b.tier end)
local function make_row(slot, data, compact)
local function make_row(tier, data, compact)
local tr = mw.html.create('tr')
local tr = mw.html.create('tr')
local sloticon = tr:tag('td')
local tiericon = tr:tag('td')
sloticon:wikitext(string.format('[[File:%s.svg|%s|link=%s|36px]]', slot.icon .. '(Skill)', slot.txt, slot.link))
tiericon:wikitext( icons.Icon({tier.link, tier.txt, img=tier.icon, type='skill'}) )
if compact then
if compact then
sloticon:attr('style', 'padding-bottom: 4px;')
tiericon:attr('style', 'padding-bottom: 4px;')
end
end
for _, v in ipairs(data) do
for _, v in ipairs(data) do
local itemicon = icons.Icon({v, img=v, type='item'})
local obstaclename = tr:tag('td'):wikitext(string.format('[[Agility#%s|%s]]', v, v))
local obstaclename = tr:tag('td'):wikitext(string.format('[[%s|%s]]', v.link, v.txt))
if compact then
if compact then
obstaclename:attr('style', 'padding-left: 12px;')
obstaclename:attr('style', 'padding-left: 12px;')
Line 54: Line 60:
-- Find the greatest row count
-- Find the greatest row count
for _, v in next, slots, nil do
for _, v in next, tiers, nil do
local grs = 0
local grs = 0
for i = 1, number_of_possible_choices, 1 do
for i = 1, number_of_possible_choices, 1 do
Line 83: Line 89:
end
end
for _, v in next, slots, nil do
for _, v in next, tiers, nil do
local row_data = {}
local row_data = {}
for i = 1, number_of_possible_choices, 1 do
for i = 1, number_of_possible_choices, 1 do
local gear = args[v.name .. i]
local obstacle = args[v.name .. i]
if gear and params.has_content(gear) then
if obstacle and params.has_content(obstacle) then
table.insert(row_data, gear)
table.insert(row_data, obstacle)
end
end
end
end


if #row_data > 0 or args.showall then
if #row_data > 0 or args.showall then
892

edits