Module:Item Products

From Guinea Isles Wiki
Revision as of 17:02, 20 September 2025 by Squeaky (talk | contribs)

Documentation for this module may be created at Module:Item Products/doc

local recipes = require('Module:Recipes')

local p = {}

function p._main(args)
	-- Get recipe data
	local item_id = nil
	if args["id"] ~= nil then
		item_id = args["id"]
	else
		item_id = mw.title.getCurrentTitle().text
	end
	
	if item_id == nil then
		return "Error: No item id found"
	end
	
	local products = recipes.get_item_products(item_id)
	if products == nil then
		return "Error: Unable to find id " .. item_id .. " in recipes through get_item_products!"
	end
	if products == {} then
		return "No products found for id " .. item_id .. " in recipes through get_item_products."
	end
	
	-- Render wikitable
	local t = mw.html.create('table')
    t:addClass('wikitable sortable products-list align-center-1 align-center-3 align-center-4 align-center-5')
    
	
	
	-- Render
	return t
end

function p.main(frame)
	local args = frame:getParent().args
	return p._main(args)
end

return p