Minecraft Wiki
Advertisement
[create | history | purge]Documentation
This module has no documentation. If you know how to use this module, please create it.
local p = {}
p.row = function( f )
	local args = f
	if f == mw.getCurrentFrame() then
		args = f:getParent().args
	else
		f = mw.getCurrentFrame()
	end
	local resource = mw.text.trim( args[1] or '' )
	local product = mw.text.trim( args[2] or '' )
	local slot = require( [[Module:Inventory slot]] )
	local sprite = require( [[Module:Sprite]] )
	local output = {}

	local title
	if args.title or '' ~= '' then
		title = args.title
	else
		local titles = {}
		for v in mw.text.gsplit( resource, '%s*,%s*' ) do
			local resources = slot.getParts( v ).name:gsub( '^Any ', '' )
			titles[ #titles + 1 ] = '[[' .. resources .. ']]'
		end
		title = mw.text.listToText( titles )
	end

	local function icon( var )
		local out = {}
		for icons in mw.text.gsplit( var, '%s*,%s*' ) do
			out[ #out + 1 ] = sprite.base{ icons, data = 'InvSprite', nourl = true }
		end
		return table.concat( out )
	end

	output[ #output + 1 ] = '|-'

	local resourceicon = resource ~= '' and '<br>' .. icon( resource ) or ''

	output[ #output + 1 ] = '| ' .. title .. resourceicon

	local products
	if args.product or '' ~= '' then
		products = args.product
	elseif product ~= '' then
		products = icon( product )
	else
		products = '—'
	end

	output[ #output + 1 ] = '| ' .. products

	if f:callParserFunction( '#var', 'renewable-method' ) == '' then
		output[ #output + 1 ] = '| ' .. ( args[3] or '' )
	end

	return table.concat( output, '\n' )
end
return p
Advertisement