17,101
edits
Falterfire (talk | contribs) (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 | local Params = require('Module:Shared/Paramtest') | ||
local | 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 = | 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 | 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 | 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 | 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 '| ' .. | return '| ' .. Icons.Icon({name, img=name, type='item'}) | ||
else | else | ||
return '| ' .. summon_icon | return '| ' .. summon_icon |