From 3d963c851fad0ca756917b7432a2b8df3032489d Mon Sep 17 00:00:00 2001 From: shagu Date: Wed, 30 Jul 2025 19:56:37 +0200 Subject: [PATCH] helpers: allow table hooks in hooksecurefunc --- helpers.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/helpers.lua b/helpers.lua index 72d5343..d4b3e80 100644 --- a/helpers.lua +++ b/helpers.lua @@ -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 = {}