Editing Module:ItemsByStat

Warning: You are not logged in. Once you make an edit, a temporary account will be created for you. Learn more. Log in or create an account to continue receiving notifications after this account expires, and to access other features.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision Your text
Line 3: Line 3:
local Lang = require("Module:Lang")
local Lang = require("Module:Lang")


-- Grab items from item data (has "upgrade" in item key and is not marked as disabled)
-- Someday there will be a field in the ItemData JSON that indicates if an item is in the game or not, until then...
ingame = {
"Basic Magazine","Close Quarters","Headshot Booster","High-Velocity Mag","Hollow Point Ward","Monster Rounds","Rapid Rounds","Restorative Shot","Reload","Berserker","Kinetic Dash","Long Range","Melee Charge",
"Mystic Shot","Slowing Bullets","Soul Shredder Bullets","Swift Striker","Fleetfoot","Burst Fire","Escalating Resilience","Headhunter","Hunter's Aura","Intensifying Magazine","Point Blank","Pristine Emblem",
"Sharpshooter","Tesla Bullets","Titanic Magazine","Toxic Bullets","Alchemical Fire","Heroic Aura","Warp Stone","Crippling Headshot","Frenzy","Glass Cannon","Lucky Shot","Ricochet","Siphon Bullets","Spiritual Overflow",
"Shadow Weave","Silencer","Vampiric Burst","Enduring Spirit","Extra Health","Extra Regen","Extra Stamina","Melee Lifesteal","Sprint Boots","Healing Rite","Bullet Armor","Bullet Lifesteal","Combat Barrier",
"Debuff Reducer","Enchanter's Barrier","Enduring Speed","Healbane","Healing Booster","Re Barrier","Spirit Armor","Spirit Lifesteal","Divine Barrier","Health Nova","Restorative Locket","Return Fire","Fortitude",
"Improved Bullet Armor","Improved Spirit Armor","Lifestrike","Superior Stamina","Veil Walker","Debuff Remover","Majestic Leap","Metal Skin","Rescue Beam","Inhibitor","Leech","Soul Rebirth","Colossus","Phantom Strike",
"Unstoppable","Ammo Scavenger","Extra Charge","Extra Spirit","Mystic Burst","Mystic Reach","Spirit Strike","Infuser","Bullet Resist Shredder","Duration Extender","Improved Cooldown","Mystic Vulnerability",
"Quicksilver Reload","Suppressor","Cold Front","Decay","Slowing Hex","Withering Whip","Improved Burst","Improved Reach","Improved Spirit","Mystic Slow","Rapid Recharge","Superior Cooldown","Superior Duration",
"Surge of Power","Torment Pulse","Ethereal Shift","Knockdown","Silence Glyph","Boundless Spirit","Diviner's Kevlar","Escalating Exposure","Mystic Reverb","Curse","Echo Shard","Magic Carpet","Refresher"
}
InGameItemData = {}
InGameItemData = {}
 
for i, InGameItemName in pairs(ingame) do
for ItemKey, ItemData in pairs(AllItemData) do
for j, ItemData in pairs(AllItemData) do
if string.find(ItemKey, "upgrade") ~= nil and ItemData["Disabled"] == false then
if ItemData["Name"]==InGameItemName then  
table.insert(InGameItemData, ItemData)
table.insert(InGameItemData, ItemData)
break
end
end
end
end
end
Line 25: Line 38:


local selectByStat = function(stat)
local selectByStat = function(stat)
-- List properties to grab, extend as necessary
-- List properties to grab and set up data structure to hold values
-- Probably not wise to move or remove elements because there's some hard-coded indexing later
local inKeys = {"Name","Tier","Cost","Slot",stat,"Components"}
local inKeys = {"Name","Tier","Cost","Slot",stat,"Components"}
local outData = {}
local outData = {}
local i = 1
local i = 1
for itemKey,itemData in pairs(InGameItemData) do
for m,itemData in pairs(InGameItemData) do
if itemData[stat] ~= nil and itemData[stat] ~= "0" then -- If Item has non-zero stat in its keys,
if itemData[stat] ~= nil and itemData[stat] ~= "0" then -- If Item has given stat in its keys,
outData[i] = {} -- start a new record of data and
outData[i] = {}
for x = 1,#inKeys do
for x = 1,#inKeys do
outData[i][x] = itemData[inKeys[x]] -- grab stat and other values
outData[i][x] = itemData[inKeys[x]] -- grab stat and other values
end
end
outData[i]['itemKey'] = itemKey -- Throw item key in there for good measure
outData[i]['multCost'] = itemData['Cost'] * multBySlot[itemData['Slot']]
i = i+1
i = i+1
end
end
Line 44: Line 54:
-- Sort by cost within slot
-- Sort by cost within slot
table.sort(outData, function(a,b) return a['multCost']<b['multCost'] end)
table.sort(outData, function(a,b) return a[3]*multBySlot[a[4]]<b[3]*multBySlot[b[4]] end)
return outData -- outData is a table of tables, one for each Item that has the specified stat, where each inner table has the data specified with inKeys, in order
return outData
end
end


--{{#invoke:ItemsByStat|tablefy|stat|statName|suffix}}
--{{#invoke:ItemsByStat|tablefy|stat|statName|suffix}}
--stat: Name of statistic to look for in ItemData.json. Must match the actual key, e.g. TechPower for Spirit Power
--statName: Column header in final table. TechPower isn't the name for the stat in-game, so change it here
--suffix: String to append to numeric value to indicate units. As of now only % and m/s are used in-game and in fact this is left blank for most stats
p.tablefy = function(frame)
p.tablefy = function(frame)
local stat = frame.args[1]
local stat = frame.args[1]
Line 59: Line 67:
local tableData = selectByStat(stat)
local tableData = selectByStat(stat)
local outString = '{| class="wikitable sortable"\n|-\n!Item!!Cost!!'..statName..'\n'
local outString = '{| class="wikitable sortable"\n|-\n!Item!!Cost!!'..statName..'\n'
for i=1,#tableData do -- Very ugly wikitable code
for i=1,#tableData do
outString = outString..
outString = outString..
'|-style="background:'..colorBySlot[tableData[i][4]]..'"\n|'..
'|-style="background:'..colorBySlot[tableData[i][4]]..'"\n|'..
frame:expandTemplate{title="Item", args={tableData[i][1]}}.."||"..
frame:expandTemplate{title="Item", args={tableData[i][1],Lang._search_string(tableData[i][1])}}.."||"..
-- frame:expandTemplate{title="Item", args={tableData[i][1],Lang.get_string(tableData[i]['itemKey'])}}.."||"..
frame:expandTemplate{title="Souls", args={tableData[i][3]}}.."||"..
frame:expandTemplate{title="Souls", args={tableData[i][3]}}.."||"..
'style="text-align:center;"|+'..tableData[i][5]..suffix.."\n"
'style="text-align:center;"|+'..tableData[i][5]..suffix.."\n"
Please note that all contributions to The 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

Page included on this page: