Module:ItemsByStat: Difference between revisionsGive feedback
SerpentofSet (talk | contribs) m More comments |
SerpentofSet (talk | contribs) mNo edit summary |
||
| (4 intermediate revisions by the same user not shown) | |||
| 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) | ||
InGameItemData = {} | InGameItemData = {} | ||
for ItemKey, ItemData in pairs(AllItemData) do | |||
if string.find(ItemKey, "upgrade") ~= nil and ItemData["Disabled"] == false then | |||
table.insert(InGameItemData, ItemData) | |||
end | end | ||
end | end | ||
| Line 34: | Line 31: | ||
local outData = {} | local outData = {} | ||
local i = 1 | local i = 1 | ||
for | for itemKey,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 non-zero stat in its keys, | ||
outData[i] = {} -- start a new record of data and | outData[i] = {} -- start a new record of data and | ||
| Line 40: | Line 37: | ||
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 45: | Line 44: | ||
-- Sort by cost within slot | -- Sort by cost within slot | ||
table.sort(outData, function(a,b) return a[ | table.sort(outData, function(a,b) return a['multCost']<b['multCost'] 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 -- 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 | ||
end | end | ||
| Line 63: | Line 62: | ||
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],Lang. | frame:expandTemplate{title="Item", args={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" | ||