Module:HeroDataArrays: Difference between revisions

Jump to navigation Jump to search
No edit summary
Health table hopefully works?
Line 1: Line 1:
local p = {}


local allHeroData = mw.loadJsonData("Data:HeroData.json")
local allHeroData = mw.loadJsonData("Data:HeroData.json")
Line 10: Line 12:
end
end


local p = {}
-- heroDataArray takes as argument a table of any length containing keys or  
 
-- paths of keys in the HeroData JSON, e.g. {Name, MaxHealth, LevelScaling>Health}.
-- heroDataArray takes as arguments any keys or path of keys in the HeroData JSON,
-- A path of keys should be specified as such, with the ">" character separating
-- e.g. Name, MaxHealth or LevelScaling>Health. A path of keys should be specified
-- subsequent keys.
-- as such, with the ">" character separating subsequent keys.
local heroDataArray = function(args)
--{{#invoke:HeroDataArrays|heroDataArray|...}}
p.heroDataArray = function(frame)
local outData = {}
local outData = {}
for i, heroData in ipairs(inGameHeroData) do -- Iterate over each hero
for i, heroData in ipairs(inGameHeroData) do -- Iterate over each hero
local out = {}
local out = {}
for j, key in pairs(frame.args) do
for j, key in pairs(args) do
if string.find(key, ">") ~= nil then -- If key is actually a path of keys,
if string.find(key, ">") ~= nil then -- If key is actually a path of keys,
local node = heroData          -- starting with the biggest node heroData,
local node = heroData          -- starting with the biggest node heroData,
Line 39: Line 39:
end
end
return(outData)
return(outData)
end
p.heroHealthTable = function()
heroHealthData = heroDataArray({"Name", "MaxHealth", "LevelScaling>Health"})
z =
[[{| class="wikitable sortable"
|+ Hero Base Health Stats
! Hero !! Starting !! Added per PI !! At Max PI
]]
for i,a in pairs(heroHealthData) do
z=z..
[[|-
| {{PageRef|]]..a["Name"]..[[|type=Hero}} || ]]..a["MaxHealth"]..[[ || ]]..a["LevelScaling>Health"]..[[ || a billion
]]
end
z = z.."|}"
return z
end
end


return p
return p