Module:Interactables

---	Interactables stores details of Risk of Rain 2' interactables --	--	@module		interactables --	@alias		p --	@author		GChinchi --	@require	Module:Interactables/Data --	@release	stable --

local interactables = mw.loadData('Module:Interactables/Data').interactables

p = {} table.unpack = unpack	-- pre-Lua 5.3 table library does not have unpack function

local galleryElement = "")	return frame:preprocess(table.concat(gallery, "\n")) end

local table_head = [=[ {| class="wikitable sortable" ! data-sort-type="string" | Name ! data-sort-type="string" | Category ! data-sort-type="string" | Cost Type ! data-sort-type="string" | Cost Value ! data-sort-type="string" | Effect ]=]

local table_row_item = [=[ ]=]
 * data-sort-value="%s" | %s
 * %s
 * %s
 * %s
 * %s
 * %s

---	Builds a wikitable of all interactables --	@function		p.AllInteractablesTable --	@param			{table} frame Frame object --	@return			{string} Preprocessed wikitext of resultant wikitable --	@usage			p.BuildAllInteractablesTable(mw.getCurrentFrame) or function p.AllInteractablesTable(frame) local categoryNames = { "Chests", "Barrels", "3D Printers", "Scrapper", "Drones", "Shrines" } local categories = {} for i, name in ipairs(categoryNames) do		categories[name] = {} end for i in pairs(interactables) do		local value = interactables[i] if value.Category ~= nil then if categories[value.Category] == nil then table.insert(categoryNames, value.Category) categories[value.Category] = {} end table.insert(categories[value.Category], value) end end local wikitable = { table_head } for i, category in pairs(categoryNames) do		local entries = categories[category] for i = 1, #entries do			local entry = entries[i] local purchaseType = "-" if entry.Purchase and entry.Purchase.Type then purchaseType = entry.Purchase.Type end table.insert(wikitable, table_row_item:format( entry.Name, entry.NameLink or entry.Name, entry.Name, category, purchaseType, entry.Purchase and entry.Purchase.Cost or "-", entry.Effect ))		end end table.insert(wikitable, "|}") return frame:preprocess(table.concat(wikitable, "")) end

return p --