Module:Sandbox/One Bar: Difference between revisions

From The Deadlock Wiki
Jump to navigation Jump to search
One Bar (talk | contribs)
typo
One Bar (talk | contribs)
remove flare
Line 43: Line 43:
-- query all the filtered items. itemName is the item table.
-- query all the filtered items. itemName is the item table.
for internalName, itemName in ipairs(filteredData) do  
for internalName, itemName in ipairs(filteredData) do  
local display = frame:expandTemplate{
local display = itemName["Name"]
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
local categoryDisplay = itemName["Slot"]
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"]

Revision as of 19:09, 10 May 2025

Documentation for this module may be created at Module:Sandbox/One Bar/doc

local p = {};
local data = mw.loadJsonData("Data:ItemData.json")

local function get_disabled_items_array()
	local similarItems = {}
	local hash = {}
	local noDuplicates = {}
	for _, v in pairs(data) do
		if (v["IsDisabled"] == true and v["Name"] ~= nil) then
			table.insert(similarItems, v)
		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
		end
	end
	return noDuplicates
end

p.disabledItemsTable = function(frame)
	local requirements = {}
	local listofItems = ""
	local filteredData = {}
	filteredData = get_disabled_items_array()
	
	local createTable = mw.html.create('table')
			:addClass('wikitable sortable')
			:tag('caption'):wikitext("List of items"):done()
		
	local createTableHeader = mw.html.create('tr')
	createTableHeader
		:tag('th'):wikitext('Name'):done()
		:tag('th'):wikitext('Category'):done()
		:tag('th'):wikitext('Description'):done()
		
	createTable:node(createTableHeader)
	
	-- query all the filtered items. itemName is the item table.
	for internalName, itemName in ipairs(filteredData) do 
		local display = itemName["Name"]
		
		listofItems = listofItems .. itemName["Name"] .. "<br/>"
		
		
		local categoryDisplay = itemName["Slot"]
		
		local description = itemName["Description"]
		
		local tableData = mw.html.create('tr')
		tableData
			:tag('td'):wikitext(display):done()
			:tag('td'):wikitext(categoryDisplay):done()
			:tag('td'):wikitext(description):done()
			
		table.insert(requirements, tableData)
			
	end	
	
	for _, row in ipairs(requirements) do
		createTable:node(row)
	end
	
	return tostring(createTable)
end

return p