![]() |
VOOZH | about |
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.
{{BiomeSprite}}{{BlockSprite}}{{EffectSprite}}{{EntitySprite}}{{EnvSprite}}{{ItemSprite}}{{InvSprite}}{{SchematicSprite}}{{SlotSprite}}{{SkinSprite}}{{MiscSprite}}{{PersonaSprite}}{{TextureSprite}}{{AchievementSprite}}{{NewAchievementSprite}}{{LegacyBlockSprite}}{{LegacyEntitySprite}}{{LegacyItemSprite}}Minecraft Dungeons
{{DungeonsLevelSprite}}{{DungeonsEnchantmentSprite}}{{DungeonsEffectSprite}}{{DungeonsEntitySprite}}{{DungeonsItemSprite}}{{DungeonsAchievementSprite}}{{DungeonsMiscellaneousSprite}}{{LegendsEntitySprite}}{{LegendsStructureSprite}}{{LegendsAchievementSprite}}{{LegendsMiscellaneousSprite}}Minecraft Story Mode
{{StoryModeAreaSprite}}{{StoryModeEntitySprite}}{{StoryModeCharacterSprite}}{{StoryModeItemSprite}}{{StoryModeAchievementSprite}}Franchise
{{AreaSprite}}{{CharacterSprite}}{{ObjectSprite}}{{LegoSprite}}{{MSSprite}}{{MovieSprite}}{{Sprite}}{{SpriteGrid}}{{Layered blueprint}}{{Schematic}}{{SchematicSprite}}{{CommentSprite}}{{FrontPageSprite}}{{ProgressSprite}}{{Tint}}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