Module:HeroDataArrays: Difference between revisionsGive feedback
Gammaton32 (talk | contribs) No edit summary |
Gammaton32 (talk | contribs) added more alt fire stats |
||
| Line 159: | Line 159: | ||
local tableDefs = { | local tableDefs = { | ||
{ | { | ||
title = "Hero Base Alt Fire Damage", | title = "Hero Base Alt-Fire Damage", | ||
columns = { | columns = { | ||
{ label = "Damage per sec", field = "altDPS" }, | { label = "Damage per sec", field = "altDPS" }, | ||
| Line 221: | Line 221: | ||
p.heroBulletSpeedTable = function(frame) | p.heroBulletSpeedTable = function(frame) | ||
local heroBulletSpeedData = heroDataArray({"Name", "Weapon>BulletSpeed"}) | local heroBulletSpeedData = heroDataArray({"Name", "Weapon>BulletSpeed", "Weapon>AltFire>BulletSpeed"}) | ||
local rows = {} | local rows = {} | ||
| Line 227: | Line 227: | ||
table.insert(rows, { | table.insert(rows, { | ||
name = name, | name = name, | ||
bulletSpeed = data["Weapon>BulletSpeed"] or 0 | bulletSpeed = data["Weapon>BulletSpeed"] or 0, | ||
altBulletSpeed = data["Weapon>AltFire>BulletSpeed"] or 0 | |||
}) | }) | ||
end | end | ||
| Line 244: | Line 245: | ||
end | end | ||
z = z.."|}" | z = z.."|}" | ||
return z | table.sort(rows, function(a, b) return a.name:lower() < b.name:lower() end) | ||
local tableDefs = { | |||
{ | |||
title = "Base Alt-Fire Bullet Velocity", | |||
columns = { | |||
{ label = "m/s", field = "altBulletSpeed" }, | |||
} | |||
} | |||
} | |||
local output = "" | |||
for _, tableDef in ipairs(tableDefs) do | |||
local filteredRows = {} | |||
for _, r in ipairs(rows) do | |||
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 | |||
return z .. "\n\n" .. output | |||
end | end | ||
p.heroClipSizeTable = function(frame) | p.heroClipSizeTable = function(frame) | ||
local heroClipSizeData = heroDataArray({"Name", "Weapon>ClipSize"}) | local heroClipSizeData = heroDataArray({"Name", "Weapon>ClipSize","Weapon>AltFire>AmmoConsumedPerShot"}) | ||
local rows = {} | local rows = {} | ||
| Line 254: | Line 313: | ||
table.insert(rows, { | table.insert(rows, { | ||
name = name, | name = name, | ||
clipSize = data["Weapon>ClipSize"] or 0 | clipSize = data["Weapon>ClipSize"] or 0, | ||
ammoConsumedPerShot = data["Weapon>AltFire>AmmoConsumedPerShot"] or 0 | |||
}) | }) | ||
end | end | ||
| Line 271: | Line 331: | ||
end | end | ||
z = z.."|}" | z = z.."|}" | ||
return z | |||
table.sort(rows, function(a, b) return a.name:lower() < b.name:lower() end) | |||
local tableDefs = { | |||
{ | |||
title = "Alt-Fire Ammo Cost", | |||
columns = { | |||
{ label = "Ammo Per Shot", field = "ammoConsumedPerShot" }, | |||
} | |||
} | |||
} | |||
local output = "" | |||
for _, tableDef in ipairs(tableDefs) do | |||
local filteredRows = {} | |||
for _, r in ipairs(rows) do | |||
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 | |||
return z .. "\n\n" .. output | |||
end | end | ||
p.heroRoundsPerSecondTable = function(frame) | p.heroRoundsPerSecondTable = function(frame) | ||
local heroRoundsPerSecondData = heroDataArray({"Name", "Weapon>RoundsPerSecond"}) | local heroRoundsPerSecondData = heroDataArray({"Name", "Weapon>RoundsPerSecond", "Weapon>AltFire>RoundsPerSecond"}) | ||
local rows = {} | local rows = {} | ||
| Line 281: | Line 400: | ||
table.insert(rows, { | table.insert(rows, { | ||
name = name, | name = name, | ||
roundsPerSecond = data["Weapon>RoundsPerSecond"] or 0 | roundsPerSecond = data["Weapon>RoundsPerSecond"] or 0, | ||
altRoundsPerSecond = data["Weapon>AltFire>RoundsPerSecond"] or 0 | |||
}) | }) | ||
end | end | ||
| Line 298: | Line 418: | ||
end | end | ||
z = z.."|}" | z = z.."|}" | ||
return z | |||
table.sort(rows, function(a, b) return a.name:lower() < b.name:lower() end) | |||
local tableDefs = { | |||
{ | |||
title = "Base Alt-Fire Fire Rate", | |||
columns = { | |||
{ label = "Rounds/s", field = "altRoundsPerSecond" }, | |||
} | |||
} | |||
} | |||
local output = "" | |||
for _, tableDef in ipairs(tableDefs) do | |||
local filteredRows = {} | |||
for _, r in ipairs(rows) do | |||
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 | |||
return z .. "\n\n" .. output | |||
end | end | ||
p.heroFalloffRangeTable = function(frame) | p.heroFalloffRangeTable = function(frame) | ||
local heroFalloffRangeData = heroDataArray({"Name", "Weapon>FalloffStartRange", "Weapon>FalloffEndRange"}) | local heroFalloffRangeData = heroDataArray({"Name", "Weapon>FalloffStartRange", "Weapon>FalloffEndRange", "Weapon>AltFire>FalloffStartRange", "Weapon>AltFire>FalloffEndRange", | ||
"Weapon>AltFire>ExplosionRadius"}) | |||
local rows = {} | local rows = {} | ||
| Line 309: | Line 489: | ||
name = name, | name = name, | ||
falloffStartRange = data["Weapon>FalloffStartRange"] or 0, | falloffStartRange = data["Weapon>FalloffStartRange"] or 0, | ||
falloffEndRange = data["Weapon>FalloffEndRange"] or 0 | falloffEndRange = data["Weapon>FalloffEndRange"] or 0, | ||
altFalloffStartRange = data["Weapon>AltFire>FalloffStartRange"] or 0, | |||
altFalloffEndRange = data["Weapon>AltFire>FalloffEndRange"] or 0, | |||
altExplosionRadius = data["Weapon>AltFire>ExplosionRadius"] or 0 | |||
}) | }) | ||
end | end | ||
| Line 326: | Line 509: | ||
end | end | ||
z = z.."|}" | z = z.."|}" | ||
return z | table.sort(rows, function(a, b) return a.name:lower() < b.name:lower() end) | ||
local tableDefs = { | |||
{ | |||
title = "Base Alt-Fire Falloff Range", | |||
columns = { | |||
{ label = "Minimum Range (m)", field = "altFalloffStartRange" }, | |||
{ label = "Maximum Range (m)", field = "altFalloffEndRange" }, | |||
{ label = "Explosion Radius (m)", field = "altExplosionRadius" }, | |||
} | |||
} | |||
} | |||
local output = "" | |||
for _, tableDef in ipairs(tableDefs) do | |||
local filteredRows = {} | |||
for _, r in ipairs(rows) do | |||
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 | |||
return z .. "\n\n" .. output | |||
end | end | ||
p.heroBulletDamageTable = function(frame) | p.heroBulletDamageTable = function(frame) | ||
-- Pull data | -- Pull data | ||
local heroBulletDamageData = heroDataArray({"Name", "Weapon>BulletDamage", "LevelScaling>BulletDamage"}) | local heroBulletDamageData = heroDataArray({"Name", "Weapon>BulletDamage", "LevelScaling>BulletDamage", "Weapon>AltFire>BulletDamage", "LevelScaling>BulletDamageAltFire"}) | ||
local rows = {} | local rows = {} | ||
| Line 338: | Line 581: | ||
name = name, | name = name, | ||
bulletDamage = tonumber(data["Weapon>BulletDamage"]) or 0, | bulletDamage = tonumber(data["Weapon>BulletDamage"]) or 0, | ||
scalingDamage = tonumber(data["LevelScaling>BulletDamage"]) or 0 | scalingDamage = tonumber(data["LevelScaling>BulletDamage"]) or 0, | ||
altBulletDamage = tonumber(data["Weapon>AltFire>BulletDamage"]) or 0, | |||
altScalingDamage = tonumber(data["LevelScaling>BulletDamageAltFire"]) or 0 | |||
}) | }) | ||
end | end | ||