Module:DaSIIWeaponBox

local insert = table.insert local concat = table.concat

local width = 7+6+7+3

local tableHeader = [===[ ]===]

local firstRow =

local cellString = [===[%s ]===]

local emptyCellString = cellString:format("–")

local rowString = [===[  %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s ]===]

local p = {}

function p.cell(string) if (string == "") then return cellString:format("???") -- TODO: Invoke "Missing" elseif (string == "-") then return emptyCellString else return cellString:format(string) end end

function p.row(attackValues, bonus, damageReduction, shield) -- TODO: This doesn't work well with condition cells (bows/shields). Fix this later return rowString:format(       p.cell(attackValues[1]),        p.cell(attackValues[2]),        p.cell(attackValues[3]),        p.cell(attackValues[4]),        p.cell(attackValues[5]),        p.cell(attackValues[6]),        p.cell(attackValues[7]),        p.cell(bonus[1]),        p.cell(bonus[2]),        p.cell(bonus[3]),        p.cell(bonus[4]),        p.cell(bonus[5]),        p.cell(bonus[6]),        p.cell(damageReduction[1]),        p.cell(damageReduction[2]),        p.cell(damageReduction[3]),        p.cell(damageReduction[4]),        p.cell(damageReduction[5]),        p.cell(damageReduction[6]),        p.cell(damageReduction[7])    ) end

function p.main(frame) local args = frame.args local result = {} insert(result, tableHeader) insert(result, firstRow) for row=1,10 do       local firstIndex = (row-1) * width local hasNonEmpty = false for i=firstIndex+1,firstIndex+width do           if args[i] ~= "" then hasNonEmpty = true break end end if hasNonEmpty == true then local attackValues = { args[firstIndex + 1], args[firstIndex + 2], args[firstIndex + 3], args[firstIndex + 4], args[firstIndex + 5], args[firstIndex + 6], args[firstIndex + 7]} local bonus = { args[firstIndex + 8], args[firstIndex + 9], args[firstIndex + 10], args[firstIndex + 11], args[firstIndex + 12], args[firstIndex + 13]} local damageReduction = { args[firstIndex + 14], args[firstIndex + 15], args[firstIndex + 16], args[firstIndex + 17], args[firstIndex + 18], args[firstIndex + 19], args[firstIndex + 20]} local shield = { args[firstIndex + 21], args[firstIndex + 22], args[firstIndex + 23]} insert(result, p.row(attackValues, bonus, damageReduction, shield)) end end insert(result, tableFooter) return concat(result, "\n") end

return p