Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:AnimateSprite

From Mine in Abyss
Revision as of 14:13, 6 October 2023 by minecraft>MarkusRost
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Usage

Implement {{AnimateSprite}}.

fr:Module:AnimateSprite



local p = {}

function p.animate( f )
	local args = f
	if f == mw.getCurrentFrame() then
		args = f:getParent().args
	end
	
	local icons = {}
	local sprite = require( 'Module:SpriteFile' ).sprite
	local name = args.name or 'InvSprite'
	
	local function image( icon )
		return sprite({
				name = name,
				icon,
				size = args.size or 32,
				align = args.align or 'middle',
				keepcase = true
			}) or ''
	end
	
	for icon in mw.text.gsplit( args[1], '%s*;%s*' ) do
		icons[#icons+1] = '<span>' .. (#icon > 0 and image( icon ) or '<br>') .. '</span>'
	end
	
	icons[1] = icons[1]:gsub( '^<span>', '<span class="animated-active">' )
	
	return '<span class="animated">' .. table.concat( icons ) .. '</span>'
end

return p
Contents