模块:Animation

来自Terraria Wiki
跳到导航 跳到搜索
亦可参看英文模块:Module:Animation。那边可能有更完整或更正确的信息。

此模块尚无文档子页面。马上创建


local VariablesLua = mw.ext.VariablesLua
local cache = mw.ext.LuaCache

local load = function()
	local status, result = pcall(function ()
		return mw.text.jsonDecode(cache.get('animation__database'))
	end)
	if status then
		return result
	else
		--fallback
		local info = require('Module:Animation/db') -- return table of mw.loadData() has a metatable, can not be used for cache.set and mw.loadData.
		cache.set( 'animation__database', mw.text.jsonEncode(info))
		return info
	end
end;

return {
	-- load database for template:animation
	-- from template: {{#invoke:animation|loadData}}
	loadData = function(frame)
		for k,v in pairs(load()) do
			VariablesLua.vardefine( 'animation:info:'..k, v )
		end
	end,

	purge = function()
		cache.delete( 'animation__database')
	end

}