更改 - 知沅教育出版社偶梦课程教研所

更改

跳到导航 跳到搜索
添加640字节 、 2024年10月27日 (日) 01:07
建立内容为“local module = {} function module.init() local hooks = {} local hookTrigger = function (name, ...) if not hooks[name] then return ... end local args = {...…”的新页面
local module = {}

function module.init()
local hooks = {}
local hookTrigger = function (name, ...)
if not hooks[name] then return ... end
local args = {...}
for _, func in ipairs(hooks[name]) do
if type(func) == 'function' then
local retn = {func(unpack(args))}
if #retn > 0 then
for idx, val in ipairs(retn) do
args[idx] = val
end
end
end
end
return unpack(args)
end
return function (list)
for name, func in pairs(list) do
if type(func) == 'function' then
hooks[name] = hooks[name] or {}
table.insert(hooks[name], func)
end
end
return hookTrigger
end
end

return module

导航菜单