VOOZH about

URL: https://minecraft.wiki/w/Module:SpriteFile

⇱ Module:SpriteFile – Minecraft Wiki


Module:SpriteFile

From Minecraft Wiki
Jump to navigation Jump to search
Documentation[view] [edit] [history] [purge]Jump to code ↴

This module implements a replacement for {{sprite}}. It should generally be invoked directly on template pages, rather than using the sprite template.

Parent arguments are automatically merged with directly passed arguments (the latter overwriting the former) and all arguments are normalized to trim whitespace and set empty arguments to nil.

Dependencies

See also

Minecraft
Minecraft (legacy)

Minecraft Dungeons

Minecraft Legends

Minecraft Story Mode

Franchise

Other
[view] [edit] [history] [purge]The above documentation is transcluded from Module:SpriteFile/doc.
localp={}
functionp.sprite(f)
localargs=f
iff==mw.getCurrentFrame()then
args=require('Module:ProcessArgs').merge(true)
else
f=mw.getCurrentFrame()
end
-- Default settings
localdefault={
scale=1,
size=16,
align='text-top'
}
localid=mw.text.trim(tostring(args[1]or''))
ifnotargs.keepcasethen
id=mw.ustring.lower(id):gsub('[%s%+]','-')
end
locallink=(args.linkor'')
ifmw.ustring.lower(link)=='none'then
link=''
elseiflink~=''then
locallinkPrefix=(notlink:find('//')andargs.linkprefix)or''
link=linkPrefix..link
end
localscale=args.scaleordefault.scale
localheight=(args.heightorargs.sizeordefault.size)*scale
localwidth=(args.widthorargs.sizeordefault.size)*scale
localsize=width..'x'..height..'px'
localstyles={}
ifheight~=default.sizethen
styles[#styles+1]='height:'..height..'px'
end
ifwidth~=default.sizethen
styles[#styles+1]='width:'..width..'px'
end
localname=args.nameor''
ifname=='InvSprite'then
name='Invicon'
end
localfile=name..' '..id..(name==''and''or'.png')
localaltText=''
iflink==''then
altText=file..': Sprite image for '..id..' in Minecraft'
end
ifid==''then
file='Grid Unknown.png'
altText='Unknown sprite image'
end
localsprite=mw.html.create('span'):addClass('sprite-file')
localimg='[[File:'..file..'|'..size..'|link='..link..'|alt='..altText..'|class=pixel-image|'..(args.titleor'')..']]'
sprite:node(img)
localalign=args.alignordefault.align
ifalign~=default.alignthen
styles[#styles+1]='--vertical-align:'..align
end
styles[#styles+1]=args.css
sprite:cssText(table.concat(styles,';'))
localroot
localspriteText
ifargs.textthen
ifnotargs['wrap']then
root=mw.html.create('span'):addClass('nowrap')
end
spriteText=mw.html.create('span'):addClass('sprite-text'):wikitext(args.text)
ifargs.titlethen
spriteText:attr('title',args.title)
end
iflink~=''then
-- External link
iflink:find('//')then
spriteText='['..link..' '..tostring(spriteText)..']'
else
spriteText='[['..link..'|'..tostring(spriteText)..']]'
end
end
end
ifnotrootthen
root=mw.html.create('')
end
root:node(sprite)
ifspriteTextthen
root:node(spriteText)
end
returntostring(root)
end
functionp.link(f)
localargs=f
iff==mw.getCurrentFrame()then
args=require('Module:ProcessArgs').merge(true)
end
locallink=args[1]
ifargs[1]andnotargs.idthen
link=args[1]:match('^(.-)%+')orargs[1]
end
localtext
ifnotargs.notextthen
text=args.textorargs[2]orlink
end
args[1]=args.idorargs[1]
args.link=args.linkorlink
args.text=text
returnp.sprite(args)
end
returnp
Retrieved from "https://minecraft.wiki/w/Module:SpriteFile?oldid=3219038"

Navigation menu