helpers: allow table hooks in hooksecurefunc

This commit is contained in:
shagu
2025-07-30 19:56:37 +02:00
parent 734932bab2
commit 3d963c851f
+8 -4
View File
@@ -85,11 +85,15 @@ ShaguTweaks.HookAddonOrVariable = function(addon, func)
end
local hooks = {}
ShaguTweaks.hooksecurefunc = function(name, func, append)
if not _G[name] then return end
ShaguTweaks.hooksecurefunc = function(tbl, name, func, append)
if type(tbl) == "string" then
append, func, name, tbl = func, name, tbl, _G
end
if not tbl or not tbl[name] then return end
hooks[tostring(func)] = {}
hooks[tostring(func)]["old"] = _G[name]
hooks[tostring(func)]["old"] = tbl[name]
hooks[tostring(func)]["new"] = func
if append then
@@ -104,7 +108,7 @@ ShaguTweaks.hooksecurefunc = function(name, func, append)
end
end
_G[name] = hooks[tostring(func)]["function"]
tbl[name] = hooks[tostring(func)]["function"]
end
local sanitize_cache = {}