Editing
Module:HeroDataArrays
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local allHeroData = mw.loadJsonData("Data:HeroData.json") local inGameHeroData = {} -- Just get heroes that are playable for i, heroData in pairs(allHeroData) do if heroData["IsDisabled"] == false and heroData["InDevelopment"] == false then table.insert(inGameHeroData, heroData) end end -- 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}. -- A path of keys should be specified as such, with the ">" character separating -- subsequent keys. local heroDataArray = function(args) local outData = {} for i, heroData in ipairs(inGameHeroData) do -- Iterate over each hero local out = {} -- First creating a table to hold data for j, key in pairs(args) do -- Iterate over each key: if string.find(key, ">") ~= nil then -- If the key is actually a path of keys, local node = heroData -- start with the biggest node heroData, and for k in string.gmatch(key, "([^>]+)") do -- iterate over each key, splitting on ">", if node[k] ~= nil then -- trying the key as a string e.g. "1", node = node[k] else -- else using the key as numeric, node = node[tonumber(k)] end -- drilling down the JSON node after node end out[key] = node -- until outputting the final node else out[key] = heroData[key] -- or just grab the data if not a path end end outData[heroData["Name"]] = out -- Save data in the big table of heroes end return(outData) end p.heroHealthTable = function(frame) -- Pull data heroHealthData = heroDataArray({"Name", "MaxHealth", "LevelScaling>MaxHealth"}) -- Input table will be called a, output wikitable will be called z -- From a to z, haha get it z = "{| class=\"wikitable sortable mw-collapsible\" style=\"text-align:center\" \n".. "|+ Hero Base Health Stats \n".. "! Hero !! Starting !! Added per PI !! At Max PI \n" -- Iterate over heroes adding a new row to the wikitable for each for i,a in pairs(heroHealthData) do z = z.. "|- \n".. "| style=\"text-align:left;\" | ".. frame:expandTemplate{title="PageRef", args={a["Name"]}}.. " || "..a["MaxHealth"].." || +"..a["LevelScaling>MaxHealth"].." || ".. tostring(tonumber(a["MaxHealth"])+tonumber(a["LevelScaling>MaxHealth"])*14).." \n" end -- Cap it off z = z.."|}" return z end p.heroRegenTable = function(frame) heroRegenData = heroDataArray({"Name", "BaseHealthRegen"}) z = "{| class=\"wikitable sortable mw-collapsible\" style=\"text-align:center\" \n".. "|+ Hero Base Health Regen \n".. "! Hero !! HP/s \n" for i,a in pairs(heroRegenData) do z = z.. "|- \n".. "| style=\"text-align:left;\" | ".. frame:expandTemplate{title="PageRef", args={a["Name"]}}.. " || "..a["BaseHealthRegen"].." \n" end z = z.."|}" return z end p.heroDpsTable = function(frame) heroDpsData = heroDataArray({"Name","ReloadSingle","ReloadDelay","ReloadTime", "ClipSize","RoundsPerSecond","BulletDamage","BulletsPerShot"}) mw.logObject(heroDpsData) end return p
Summary:
Please note that all contributions to Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Deadlock:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Template used on this page:
Module:HeroDataArrays/doc
(
edit
)
Navigation menu
Personal tools
English
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit source
View history
More
Search
Navigation
Main page
Discord community
Recent changes
Random page
Tools
What links here
Related changes
Special pages
Page information
Languages