Module:ProfessionBox
Jump to navigation
Jump to search
Documentation for this module may be created at Module:ProfessionBox/doc
local getArgs = require('Module:Arguments').getArgs
local p = {}
function p.GenerateTable(frame)
local args = getArgs(frame, {wrappers = 'Template:ProfessionBox'})
local tableStr = ""
if args.q1 ~= nil and args.q2 ~= nil then
--Check if item has multiple Ranks
if args.q2r2 == nil then
tableStr = tableStr .. "{| class='darktable' cellpadding='2' cellspacing='1'\n|+ Materials Required\n|-\n"
else
tableStr = tableStr .. "{| class='darktable' cellpadding='2' cellspacing='1'\n|+ Materials Required (Rank 1)\n|-\n"
end
--Loop through each item
for i = 1, 4 do
--Loop through each rank
for j = 1, 4 do
local result = nil
if i == 1 then
result = frame:callParserFunction("#using:"..args.item..i,{"Itembox/entry",["quantity"] = "q"..i,})
else
result = frame:callParserFunction("#using:"..args.item.i,{"Itembox/entry",["quantity"] = "q"..i.."r"..j,})
end
if i == 4 and j == 4 then
tableStr = tableStr .. result
elseif result ~= nil then
tableStr = tableStr .. result .. "|-"
end
end
end
--Close table
tableStr = tableStr .. "\n|}"
else
return "Error. Reagents and Quantities must be filled out"
end
return tableStr
end
return p