From e003c6b3773eeffe663fca5f5b03754fa1503f86 Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 26 Feb 2017 17:47:53 +0100 Subject: [PATCH] api: allow multiple hooks --- env/api.lua | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/env/api.lua b/env/api.lua index 5f27914f..b8851bc5 100644 --- a/env/api.lua +++ b/env/api.lua @@ -50,25 +50,24 @@ end -- code instead of prepending it function pfUI.api.Hook(name, func, append) if not _G[name] then return end - if pfUI.hooks[name] then return end - pfUI.hooks[name] = {} - pfUI.hooks[name]["old"] = _G[name] - pfUI.hooks[name]["new"] = func + pfUI.hooks[tostring(func)] = {} + pfUI.hooks[tostring(func)]["old"] = _G[name] + pfUI.hooks[tostring(func)]["new"] = func if append then - pfUI.hooks[name]["function"] = function(...) - pfUI.hooks[name]["old"](unpack(arg)) - pfUI.hooks[name]["new"](unpack(arg)) + pfUI.hooks[tostring(func)]["function"] = function(...) + pfUI.hooks[tostring(func)]["old"](unpack(arg)) + pfUI.hooks[tostring(func)]["new"](unpack(arg)) end else - pfUI.hooks[name]["function"] = function(...) - pfUI.hooks[name]["new"](unpack(arg)) - pfUI.hooks[name]["old"](unpack(arg)) + pfUI.hooks[tostring(func)]["function"] = function(...) + pfUI.hooks[tostring(func)]["new"](unpack(arg)) + pfUI.hooks[tostring(func)]["old"](unpack(arg)) end end - _G[name] = pfUI.hooks[name]["function"] + _G[name] = pfUI.hooks[tostring(func)]["function"] end -- [ Create Gold String ]