Module:Item

From Create: Minecraft Mod Wiki
Revision as of 14:19, 30 April 2021 by Create: Minecraft Mod Wiki>Joker876
Jump to navigation Jump to search

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

local p = {}

function p.item(f)
	local args = f
	if f == mw.getCurrentFrame() then
		args = f:getParent().args
	else
		f = mw.getCurrentFrame()
	end
	
	local isMCwiki = args.minecraft or args.mc
	local item = args[1] or args.item or args.i
	local img = args.image or args.img or item
	local alt = args[2] or item
	local link = args.link or item
	local title = item
	local imgsize = args.size or "21px"
	if isMCwiki then
		link = 'w:c:minecraft:'..link
		title = 'Minecraft Wiki: '..title
	end
	if true then return tostring(img)..';;'..tostring(item) end
	local ret = mw.html.create('span')
		:wikitext(table.concat{
			'[[File:', img, '.png|', imgsize, '|link=', link, ']]&nbsp;[[', link, '|<span title="', title, '">', alt, '</span>]]' 
		})
	return tostring(ret)
end

return p