helpers: make hooksecurefunc append by default

This commit is contained in:
shagu
2025-07-30 20:26:29 +02:00
parent 3d963c851f
commit 344354d975
7 changed files with 17 additions and 19 deletions
+5 -5
View File
@@ -85,9 +85,9 @@ ShaguTweaks.HookAddonOrVariable = function(addon, func)
end
local hooks = {}
ShaguTweaks.hooksecurefunc = function(tbl, name, func, append)
ShaguTweaks.hooksecurefunc = function(tbl, name, func, prepend)
if type(tbl) == "string" then
append, func, name, tbl = func, name, tbl, _G
prepend, func, name, tbl = func, name, tbl, _G
end
if not tbl or not tbl[name] then return end
@@ -96,15 +96,15 @@ ShaguTweaks.hooksecurefunc = function(tbl, name, func, append)
hooks[tostring(func)]["old"] = tbl[name]
hooks[tostring(func)]["new"] = func
if append then
if prepend then
hooks[tostring(func)]["function"] = function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
hooks[tostring(func)]["old"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
hooks[tostring(func)]["new"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
hooks[tostring(func)]["old"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
end
else
hooks[tostring(func)]["function"] = function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
hooks[tostring(func)]["new"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
hooks[tostring(func)]["old"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
hooks[tostring(func)]["new"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
end
end