Editing Module:Sandbox/One BarGive feedback
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 1: | Line 1: | ||
local p = {}; | local p = {}; | ||
local | local data = mw.loadJsonData("Data:ItemData.json") | ||
local function | local function get_disabled_items_array() | ||
local | local similarItems = {} | ||
local hash = {} | |||
local noDuplicates = {} | |||
for _, v in pairs(data) do | |||
local | if (v["IsDisabled"] == true and v["Name"] ~= nil) then | ||
local | table.insert(similarItems, v) | ||
if ( | |||
end | end | ||
end | end | ||
-- remove duplicate items if that item contains multiple keys of the same stat increase (eg. Fleetfoot has both "BonusMoveSpeed", "ActiveBonusMoveSpeed" in move speed). | |||
-- there might be a more efficient way to prevent adding duplicate items in the first place in the above for loop | |||
for _, v in pairs(similarItems) do | |||
if (not hash[v]) then | |||
noDuplicates[#noDuplicates+1] = v | |||
hash[v] = true | |||
for _, | |||
end | end | ||
end | end | ||
return noDuplicates | |||
return | |||
end | end | ||
| Line 111: | Line 35: | ||
local createTableHeader = mw.html.create('tr') | local createTableHeader = mw.html.create('tr') | ||
createTableHeader | createTableHeader | ||
:tag('th'):wikitext('Name'):done() | :tag('th'):wikitext('Name'):done() | ||
:tag('th'):wikitext('Category'):done() | :tag('th'):wikitext('Category'):done() | ||
| Line 119: | Line 42: | ||
-- query all the filtered items. itemName is the item table. | -- query all the filtered items. itemName is the item table. | ||
for internalName, itemName in | for internalName, itemName in ipairs(filteredData) do | ||
local display = itemName["Name"] | local display = frame:expandTemplate{ | ||
title = 'ItemIcon', | |||
args = { | |||
itemName["Name"] | |||
} | |||
} | |||
listofItems = listofItems .. itemName["Name"] .. "<br/>" | listofItems = listofItems .. itemName["Name"] .. "<br/>" | ||
-- Get category display using ItemType template with appropriate parameters | |||
local categoryDisplay = itemName["Slot"] | local categoryDisplay | ||
if itemName["Slot"] == "Armor" then | |||
categoryDisplay = frame:expandTemplate{ | |||
title = 'ItemType', | |||
args = { "Armor", "Vitality" } | |||
} | |||
elseif itemName["Slot"] == "Tech" then | |||
categoryDisplay = frame:expandTemplate{ | |||
title = 'ItemType', | |||
args = { "Tech", "Spirit" } | |||
} | |||
else -- Weapon | |||
categoryDisplay = frame:expandTemplate{ | |||
title = 'ItemType', | |||
args = { "Weapon", "Weapon" } | |||
} | |||
end | |||
local description = itemName["Description"] | local description = itemName["Description"] | ||
| Line 131: | Line 75: | ||
local tableData = mw.html.create('tr') | local tableData = mw.html.create('tr') | ||
tableData | tableData | ||
:tag('td'):wikitext(display):done() | :tag('td'):wikitext(display):done() | ||
:tag('td'):wikitext(categoryDisplay):done() | :tag('td'):wikitext(categoryDisplay):done() | ||