Module:Equipment/Recommended: Difference between revisions

main: Modify to allow passing of plaintext as equipment parameters; consistency of Module variables with other modules
(Removed superfluous closing bracket)
(main: Modify to allow passing of plaintext as equipment parameters; consistency of Module variables with other modules)
Line 4: Line 4:
local p = {}
local p = {}


local params = require('Module:Shared/Paramtest')
local Params = require('Module:Shared/Paramtest')
local icons = require("Module:Icons")
local Icons = require("Module:Icons")


local slots = {
local slots = {
Line 45: Line 45:
end
end
for _, v in ipairs(data) do
for _, v in ipairs(data) do
local itemicon = icons.Icon({v, img=v, type='item'})
local itemicon = nil
if string.find(v, '!', 1, true) then
-- ! prefix, treat as plain text
itemicon = string.sub(v, 2, -1)
else
-- Otherwise treat as an item icon
itemicon = Icons.Icon({v, img=v, type='item'})
end
local gearname = tr:tag('td'):wikitext(itemicon)
local gearname = tr:tag('td'):wikitext(itemicon)
if compact then
if compact then
Line 65: Line 72:
for i = 1, number_of_possible_choices, 1 do
for i = 1, number_of_possible_choices, 1 do
local check = args[v.name .. i]
local check = args[v.name .. i]
if check and params.has_content(check) then
if check and Params.has_content(check) then
grs = grs + 1
grs = grs + 1
end
end
Line 77: Line 84:
local parent = mw.html.create('table')
local parent = mw.html.create('table')
-- If setname is passed in, apply it above the table
-- If setname is passed in, apply it above the table
if args.setname and params.has_content(args.setname) then
if args.setname and Params.has_content(args.setname) then
parent:tag('caption'):wikitext(string.format('Recommended equipment for %s', args.setname))
parent:tag('caption'):wikitext(string.format('Recommended equipment for %s', args.setname))
end
end
Line 94: Line 101:
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 gear = args[v.name .. i]
if gear and params.has_content(gear) then
if gear and Params.has_content(gear) then
table.insert(row_data, gear)
table.insert(row_data, gear)
end
end
Line 129: Line 136:
local function make_gear_cell(name)
local function make_gear_cell(name)
if name then
if name then
return '| ' .. icons.Icon({name, img=name, type='item'})
return '| ' .. Icons.Icon({name, img=name, type='item'})
else
else
return '| ' .. summon_icon
return '| ' .. summon_icon