Binding of Isaac: Rebirth Wiki
Advertisement

Documentation for this module may be created at Module:Bag of crafting recipes/doc

local p = {}
local cargo = mw.ext.cargo
local w_frame = require( 'module:frame' )
local data = mw.loadData( 'module:bag of crafting recipes/data' )

function p.recipe( f )
	return recipe( w_frame.args( f ) )
end
function recipe( r )
	local intro = '<div class="crafting-recipe"'
	if r[2] then
		intro = intro .. ' data-next-crafting-recipe="' .. r[2]
		local n = ipairs( r )
		for _, v in n, r, 2 do
			intro = intro .. '|' .. v
		end
		intro = intro .. '"'
	end
	r = r[1]
	return intro .. '>' ..
		data.components[r:byte( 1 ) - 0x61] ..
		data.components[r:byte( 2 ) - 0x61] ..
		data.components[r:byte( 3 ) - 0x61] ..
		data.components[r:byte( 4 ) - 0x61] ..
		data.components[r:byte( 5 ) - 0x61] ..
		data.components[r:byte( 6 ) - 0x61] ..
		data.components[r:byte( 7 ) - 0x61] ..
		data.components[r:byte( 8 ) - 0x61] ..
		'</div>'
end

function p.tableOfRecipes( f )
	return '|-\n| Recipes unavailable at this time'
end

p['table'] = function ( f )
	local args  = w_frame.args( f )
	local frame = mw.getCurrentFrame()
	
	local where = 'id >= ' .. ( args[1] or '1' )
	if args[2] then
		where = where .. ' and id < ' .. args[2]
	end
	if args.type == 'active' then
		where = where .. ' and not is_activated'
	elseif args.type == 'passive' then
		where = where .. ' and is_activated'
	end
	
	local qres = cargo.query( 'collectible', '_pageName = page, dlc, alias, name, image, id', {
		where   = where,
		orderBy = 'id',
		limit   = 800
	} )

	-- Expand the row templates once per item
	local lines = {}
	for _, v in ipairs( qres ) do
		local recipes = data.recipes[tonumber( v.id )]
		if recipes ~= nil then
			table.insert( lines, '|-' )
			table.insert( lines, '| ' .. frame:expandTemplate{ title = 'i/query', args = v } )
			table.insert( lines, '| ' .. tostring( v.id ) )
			table.insert( lines, '| ' .. recipe( recipes ) )
		end
	end
	return table.concat( lines, '\n' )
end

return p
Advertisement