Module:JobEquipmentList/sandbox

local cargo = require('Module:CargoUtil') local render_item_icon = require('Module:Render/Item')._icon

local p = {} local h = {}

local maxEquipSlots = 6

function p.jobEquipmentList(frame) local iname = frame.args[1] return p._jobEquipmentList(iname) end

function p._jobEquipmentList(iname) if iname == nil then return 'Invalid parameter' end local jobs = cargo.query{ tables = 'JobRank', fields = 'idx, eqid1, eqid2, eqid3, eqid4, eqid5, eqid6, learn1, learn2', where = 'job_iname = "'.. iname ..'" AND server = "gl"', }   if #jobs == 0 then return 'Equipment data not found for '..iname end local output = { '{| class="wikitable" style="width:calc(100% - 20px); background-color:#e0e0e0"', '|- style="background-color:#cbac02; font-weight:bold"', '| style="text-align:center" |Level', '| style="text-align:center" |Equipment' }   for _,entry in pairs( jobs ) do    	local level = tonumber(entry.idx) table.insert(output, h.convertRankToJobLevelRow(entry, level)) end table.insert(output, '|}') return table.concat(output, "\n") end

function h.convertRankToJobLevelRow(rank, level) local pieces = {'|- '}

local jobLevel = 'Level '..(level - 1) if (level == 1) then jobLevel = 'Unlock Job' end table.insert(pieces, '|style="text-align:center; font-weight:bold"|'..jobLevel) local equip = {} for r = 1, maxEquipSlots do       local tempKey = 'eqid'..r        table.insert(equip, render_item_icon({rank[tempKey]})) end table.insert(pieces, '| '..table.concat(equip)..' ') return table.concat(pieces, "\n") end

function p.test(frame) local args = require("Module:Arguments").getArgs(frame) return p._jobEquipmentList(args[1]) end

return p