Please note that some information on this wiki is still based on the demo version.
If you notice any errors, feel free to correct them.

Module:ItemList

From Super Fantasy Kingdom Official Wiki

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

local p = {}

function p.itemlist( f )
	local args = f:getParent().args
	
	-- items can be one per arg or a comma separated list in one arg
	-- split first value at comma, e.g. from cargo list field
	local items = {}
	for v in mw.text.gsplit(args[1], ',', true) do
		if #v > 0 then -- ignore empty items
			table.insert(items, v)
		end
	end

	-- append other args
	for _,v in ipairs(args) do 
		if _ > 1 and #v > 0 then
			table.insert(items, v)
		end
	end
	
	local output = {}
	for _,v in ipairs(items) do
		table.insert(output, f:expandTemplate{ title = 'ItemLink', args = { v } })
	end
	
	return table.concat(output, '<br>')
end

return p