Module:ItemTables: Difference between revisionsGive feedback
add more keys, add unit suffix |
add comment, add filter function WIP |
||
| Line 14: | Line 14: | ||
end | end | ||
return formatted | return formatted | ||
end | |||
-- Returns an array of item tables that have the same properties | |||
-- @function get_similar_items | |||
-- @param {array} | |||
-- @return {array of tables} | |||
local function get_similar_items(property) | |||
local similarItems = {} | |||
for _, v in pairs(data) do | |||
for _, value in ipairs(property) do | |||
if (v[value] ~= nil) then | |||
table.insert(similarItems, v) | |||
end | |||
end | |||
end | |||
return similarItems | |||
end | end | ||
| Line 68: | Line 84: | ||
friendly_to_internal["stamina recovery"] = { "StaminaCooldownReduction" } | friendly_to_internal["stamina recovery"] = { "StaminaCooldownReduction" } | ||
-- Returns a table of internal properties | |||
-- @function friendlyNames | |||
-- @param {string} | |||
-- @return {table} | |||
local function friendlyNames(desc) | local function friendlyNames(desc) | ||
local keysTable = {} | local keysTable = {} | ||
| Line 101: | Line 121: | ||
local copyVar = property | local copyVar = property | ||
listofKeysTable = friendlyNames(property) | listofKeysTable = friendlyNames(property) | ||
local filteredTable = {} | |||
filteredTable = get_similar_items(listofKeysTable) | |||
local createTable = mw.html.create('table') | local createTable = mw.html.create('table') | ||
| Line 114: | Line 137: | ||
createTable:node(createTableRow) | createTable:node(createTableRow) | ||
-- query all items | -- query all items | ||
for internalName, itemName in pairs(data) do --itemName is the key. go through whole table. in this case itemName is the item table | for internalName, itemName in pairs(data) do --itemName is the key. go through whole table. in this case itemName is the item table | ||