Minecraft Wiki

除另有声明,转载时均必须注明出处若簡繁轉換出錯,請以遊戲內為準请勇于扩充与修正内容有兴趣逛逛我们的微博沟通交流,欢迎到社区专页需要协助,请在告示板留言

了解更多

Minecraft Wiki
Advertisement

本模块用于实现{{AnimateSprite}}

local p = {}

function p.animate( f )
	local args = f
	if f == mw.getCurrentFrame() then
		args = f:getParent().args
	end
	
	local icons = {}
	local sheet = args.sheet or 'InvSprite'
	for icon in mw.text.gsplit( args[1], '%s*;%s*' ) do
		function image( icon )
			local ids = mw.loadData( 'Module:' .. sheet ).ids
			local sprite = require( 'Module:Sprite' ).sprite
			local idData = ids[icon] or { pos = 1 , section = 0 }
			local image
	
			if idData then
				image = sprite{
					iddata = idData,
					data = sheet
				}
			end

			return image
		end
		
		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
Advertisement