Module:ItemTables: Difference between revisionsGive feedback
apply filtered table, rearrange checks |
setup default sorting |
||
| Line 4: | Line 4: | ||
local get_type = require("Module:ItemData")._get_type | local get_type = require("Module:ItemData")._get_type | ||
--[===[ | |||
-- Adds commas delimiter to the thousands place | -- Adds commas delimiter to the thousands place | ||
function Format(amount) | function Format(amount) | ||
| Line 15: | Line 16: | ||
return formatted | return formatted | ||
end | end | ||
--]===] | |||
-- Returns an array of item tables that have the same properties | -- Returns an array of item tables that have the same properties | ||
| Line 111: | Line 113: | ||
return unitName | return unitName | ||
end | end | ||
local sortByWeapon = {} | |||
sortByWeapon["Weapon"] = 1 | |||
sortByWeapon["Armor"] = 10000 | |||
sortByWeapon["Tech"] = 100000000 | |||
-- Outputs a wikitable of items that increase a specified stat. Invoked by {{Item stat table}} | -- Outputs a wikitable of items that increase a specified stat. Invoked by {{Item stat table}} | ||
| Line 126: | Line 133: | ||
local filteredData = {} | local filteredData = {} | ||
filteredData = get_similar_items_array(listofKeysTable) | filteredData = get_similar_items_array(listofKeysTable) | ||
table.sort(filteredData, function(a,b) return get_cost(a["Name"]) * sortByWeapon[a["Slot"]] < get_cost(b["Name"]) * sortByWeapon[b["Slot"]] end) | |||
local createTable = mw.html.create('table') | local createTable = mw.html.create('table') | ||