Module:Item: Difference between revisions
Jump to navigation
Jump to search
Create: Minecraft Mod Wiki>Joker876 No edit summary |
Create: Minecraft Mod Wiki>Joker876 No edit summary |
||
Line 3: | Line 3: | ||
function p.item(f) | function p.item(f) | ||
local args = require( [[Module:ProcessArgs]] ).norm(f, true) | local args = require( [[Module:ProcessArgs]] ).norm(f, true) | ||
mw.logObject(args) | |||
mw.logObject(f) | |||
local isMCwiki = args.minecraft or args.mc | local isMCwiki = args.minecraft or args.mc | ||
local item = args[1] or args.item or args.i | local item = args[1] or args.item or args.i | ||
local img = args.image or args.img or item | local img = args.image or args.img or item | ||
local alt = args[2] or item | local alt = args[2] or item | ||
local link = args.link or item | local link = args.link or item |
Revision as of 14:07, 30 April 2021
Documentation for this module may be created at Module:Item/doc
local p = {}
function p.item(f)
local args = require( [[Module:ProcessArgs]] ).norm(f, true)
mw.logObject(args)
mw.logObject(f)
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
local ret = mw.html.create('span')
:wikitext(table.concat{
'[[File:', img, '.png|', imgsize, '|link=', link, ']] [[', link, '|<span title="', title, '">', alt, '</span>]]'
})
return tostring(ret)
end
return p