Module:HeroData: Difference between revisions

Sur (talk | contribs)
m postfix bugfix
Sur (talk | contribs)
m write_hero_comparison_table initial
Line 343: Line 343:
return template_calls .. "</div>"
return template_calls .. "</div>"
end
--writes the massive hero comparison table for a specific PI and SP
--{{#invoke:HeroData|write_hero_comparison_table|POWER_INCREASES|SPIRIT_POWER}}
p.write_hero_comparison_table = function(frame)
-- process inputs
local power_increases = frame.args[1]
if (power_increases == nil) then power_increases = 0 end
local spirit_power = frame.args[2]
if (spirit_power == nil) then spirit_power = 0 end
-- get all headers
local headers_str = ""
local headers = {}
headers[1] = "Hero"
headers[2] = "Health"
headers[3] = "DPS"
for index, header in ipairs(headers) do
headers_str = headers_str .. "<th>" .. header .. "</th>"
end
headers_str = "<tr>" .. headers_str .. "</tr>"
local row_str = ""
local body_str = ""
local heroes = {}
heroes[1] = "Abrams"
heroes[2] = "McGinnis"
heroes[3] = "Seven"
for index, hero in ipairs(heroes) do
local stats = {}
stats[1] = "Health"
stats[2] = "DPS"
--Add the row's stats
row_str = ""
-- First column in each row is hero name
row_str = row_str .. "<td>" .. hero .. "</td>"
-- Consecutive columns are then stats
for index, stat in ipairs(stats) do
row_str = row_str .. "<td>" .. stat .. "</td>"
end
row_str = "<tr>" .. row_str .. "</tr>"
-- Add row to the body
body_str = body_str .. row_str
end
return '<table class="wikitable sortable">' .. headers_str .. body_str .. "</table>"
end
end


return p
return p