|
|
| Line 160: |
Line 160: |
| table.sort(rows, function(a, b) return a.name:lower() < b.name:lower() end) | | table.sort(rows, function(a, b) return a.name:lower() < b.name:lower() end) |
|
| |
|
| local z = "{| class=\"wikitable sortable mw-collapsible\" style=\"text-align:center\" \n".. | | local tableDefs = { |
| "|+ Hero Base Health Regen \n".. | | { |
| "! Hero !! HP/s \n"
| | title = "Hero Base Health Regen", |
| | columns = { |
| | { label = "HP/s", field = "baseHealthRegen" } |
| | } |
| | } |
| | } |
|
| |
|
| for _, r in ipairs(rows) do | | local output = {} |
| z = z.. | | for _, def in ipairs(tableDefs) do |
| "|- \n"..
| | local t = buildTable(frame, rows, def, def.options) |
| "| style=\"text-align:left;\" | ".. | | if t ~= "" then |
| frame:expandTemplate{title="PageRef", args={r.name}}..
| | table.insert(output, t) |
| " || "..r.baseHealthRegen.." \n"
| | end |
| end | | end |
| z = z.."|}" | | |
| return z
| | return table.concat(output, "\n\n") |
| end | | end |
|
| |
|
| Line 748: |
Line 753: |
| } | | } |
|
| |
|
| local output = "" | | local output = {} |
| | | for _, def in ipairs(tableDefs) do |
| for _, tableDef in ipairs(tableDefs) do | | local t = buildTable(frame, rows, def, def.options) |
| local filteredRows = {} | | if t ~= "" then |
| for _, r in ipairs(rows) do
| | table.insert(output, t) |
| local hasValue = false
| |
| for _, col in ipairs(tableDef.columns) do
| |
| if r[col.field] ~= 0 then
| |
| hasValue = true
| |
| break
| |
| end
| |
| end | |
| if hasValue then
| |
| table.insert(filteredRows, r)
| |
| end
| |
| end
| |
| | |
| if #filteredRows > 0 then
| |
| local header = ""
| |
| for _, col in ipairs(tableDef.columns) do
| |
| header = header.." !! "..col.label
| |
| end
| |
| | |
| local t = "{| class=\"wikitable sortable mw-collapsible\" style=\"text-align:center\" \n"..
| |
| "|+ "..tableDef.title.." \n"..
| |
| "! Hero"..header.." \n"
| |
| | |
| for _, r in ipairs(filteredRows) do
| |
| local cells = ""
| |
| for _, col in ipairs(tableDef.columns) do
| |
| cells = cells.." || "..r[col.field]
| |
| end
| |
| t = t..
| |
| "|- \n"..
| |
| "| style=\"text-align:left;\" | "..
| |
| frame:expandTemplate{title="PageRef", args={r.name}}..
| |
| cells.." \n"
| |
| end
| |
| | |
| t = t.."|}"
| |
| if output ~= "" then
| |
| output = output.."\n\n"
| |
| end
| |
| output = output..t
| |
| end | | end |
| end | | end |
|
| |
|
| return output | | return table.concat(output, "\n\n") |
| end | | end |
|
| |
|
| Line 872: |
Line 838: |
| } | | } |
|
| |
|
| local output = "" | | local output = {} |
| | | for _, def in ipairs(tableDefs) do |
| for _, tableDef in ipairs(tableDefs) do | | local t = buildTable(frame, rows, def, def.options) |
| local filteredRows = {} | | if t ~= "" then |
| for _, r in ipairs(rows) do
| | table.insert(output, t) |
| local hasValue = false
| |
| for _, col in ipairs(tableDef.columns) do
| |
| if r[col.field] ~= 0 then
| |
| hasValue = true
| |
| break
| |
| end
| |
| end | |
| if hasValue then
| |
| table.insert(filteredRows, r)
| |
| end
| |
| end
| |
| | |
| if #filteredRows > 0 then
| |
| local header = ""
| |
| for _, col in ipairs(tableDef.columns) do
| |
| header = header.." !! "..col.label
| |
| end
| |
| | |
| local t = "{| class=\"wikitable sortable mw-collapsible\" style=\"text-align:center\" \n"..
| |
| "|+ "..tableDef.title.." \n"..
| |
| "! Hero"..header.." \n"
| |
| | |
| for _, r in ipairs(filteredRows) do
| |
| local cells = ""
| |
| for _, col in ipairs(tableDef.columns) do
| |
| cells = cells.." || "..r[col.field]
| |
| end
| |
| t = t..
| |
| "|- \n"..
| |
| "| style=\"text-align:left;\" | "..
| |
| frame:expandTemplate{title="PageRef", args={r.name}}..
| |
| cells.." \n"
| |
| end
| |
| | |
| t = t.."|}"
| |
| if output ~= "" then
| |
| output = output.."\n\n"
| |
| end
| |
| output = output..t
| |
| end | | end |
| end | | end |
|
| |
|
| return output | | return table.concat(output, "\n\n") |
| end | | end |
|
| |
|
| Line 943: |
Line 870: |
| } | | } |
|
| |
|
| local output = "" | | local output = {} |
| | | for _, def in ipairs(tableDefs) do |
| for _, tableDef in ipairs(tableDefs) do | | local t = buildTable(frame, rows, def, def.options) |
| local filteredRows = {} | | if t ~= "" then |
| for _, r in ipairs(rows) do
| | table.insert(output, t) |
| local hasValue = false
| |
| for _, col in ipairs(tableDef.columns) do
| |
| if r[col.field] ~= 0 then
| |
| hasValue = true
| |
| break
| |
| end
| |
| end | |
| if hasValue then
| |
| table.insert(filteredRows, r)
| |
| end
| |
| end
| |
| | |
| if #filteredRows > 0 then
| |
| local header = ""
| |
| for _, col in ipairs(tableDef.columns) do
| |
| header = header.." !! "..col.label
| |
| end
| |
| | |
| local t = "{| class=\"wikitable sortable mw-collapsible\" style=\"text-align:center\" \n"..
| |
| "|+ "..tableDef.title.." \n"..
| |
| "! Hero"..header.." \n"
| |
| | |
| for _, r in ipairs(filteredRows) do
| |
| local cells = ""
| |
| for _, col in ipairs(tableDef.columns) do
| |
| cells = cells.." || "..r[col.field]
| |
| end
| |
| t = t..
| |
| "|- \n"..
| |
| "| style=\"text-align:left;\" | "..
| |
| frame:expandTemplate{title="PageRef", args={r.name}}..
| |
| cells.." \n"
| |
| end
| |
| | |
| t = t.."|}"
| |
| if output ~= "" then
| |
| output = output.."\n\n"
| |
| end
| |
| output = output..t
| |
| end | | end |
| end | | end |
|
| |
|
| return output | | return table.concat(output, "\n\n") |
| end | | end |
|
| |
|
| return p | | return p |