您似乎还未注册一个账号?我们强烈推荐您点击此处创建一个账户。|如果您在H萌娘上发现某些内容错误/空缺/不中立,请勇于按右上角编辑按钮!
Module:HooksHandler
跳转到导航
跳转到搜索
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