helpers: make hooksecurefunc append by default
This commit is contained in:
+5
-5
@@ -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
|
||||
|
||||
|
||||
+3
-3
@@ -381,7 +381,7 @@ hooksecurefunc("CastSpell", function(id, bookType)
|
||||
local spellName = GetSpellName(id, bookType)
|
||||
CastCustom(spellName)
|
||||
end
|
||||
end, true)
|
||||
end)
|
||||
|
||||
hooksecurefunc("CastSpellByName", function(spell, target)
|
||||
_, lastrank = libspell.GetSpellInfo(spell)
|
||||
@@ -393,7 +393,7 @@ hooksecurefunc("CastSpellByName", function(spell, target)
|
||||
return
|
||||
end
|
||||
end
|
||||
end, true)
|
||||
end)
|
||||
|
||||
hooksecurefunc("UseAction", function(slot, target, button)
|
||||
scanner:SetAction(slot)
|
||||
@@ -404,6 +404,6 @@ hooksecurefunc("UseAction", function(slot, target, button)
|
||||
|
||||
if GetActionText(slot) or not IsCurrentAction(slot) then return end
|
||||
CastCustom(spellName)
|
||||
end, true)
|
||||
end)
|
||||
|
||||
ShaguTweaks.libcast = libcast
|
||||
|
||||
+3
-3
@@ -224,13 +224,13 @@ hooksecurefunc("CastSpell", function(id, bookType)
|
||||
local _, rank = libspell.GetSpellInfo(id, bookType)
|
||||
local duration = libdebuff:GetDuration(effect, rank)
|
||||
libdebuff:AddPending(UnitName("target"), UnitLevel("target"), effect, duration)
|
||||
end, true)
|
||||
end)
|
||||
|
||||
hooksecurefunc("CastSpellByName", function(effect, target)
|
||||
local _, rank = libspell.GetSpellInfo(effect)
|
||||
local duration = libdebuff:GetDuration(effect, rank)
|
||||
libdebuff:AddPending(UnitName("target"), UnitLevel("target"), effect, duration)
|
||||
end, true)
|
||||
end)
|
||||
|
||||
hooksecurefunc("UseAction", function(slot, target, button)
|
||||
if GetActionText(slot) or not IsCurrentAction(slot) then return end
|
||||
@@ -238,7 +238,7 @@ hooksecurefunc("UseAction", function(slot, target, button)
|
||||
local effect, rank = scanner:Line(1)
|
||||
local duration = libdebuff:GetDuration(effect, rank)
|
||||
libdebuff:AddPending(UnitName("target"), UnitLevel("target"), effect, duration)
|
||||
end, true)
|
||||
end)
|
||||
|
||||
function libdebuff:UnitDebuff(unit, id)
|
||||
local unitname = UnitName(unit)
|
||||
|
||||
+3
-3
@@ -304,7 +304,7 @@ hooksecurefunc("CastSpell", function(id, bookType)
|
||||
spell_queue[1] = effect
|
||||
spell_queue[2] = effect.. ( rank or "" )
|
||||
spell_queue[3] = UnitName("target") and UnitCanAssist("player", "target") and UnitName("target") or UnitName("player")
|
||||
end, true)
|
||||
end)
|
||||
|
||||
hooksecurefunc("CastSpellByName", function(effect, target)
|
||||
if not libpredict.sender.enabled then return end
|
||||
@@ -313,7 +313,7 @@ hooksecurefunc("CastSpellByName", function(effect, target)
|
||||
spell_queue[1] = effect
|
||||
spell_queue[2] = effect.. ( rank or "" )
|
||||
spell_queue[3] = UnitName("target") and UnitCanAssist("player", "target") and UnitName("target") or UnitName("player")
|
||||
end, true)
|
||||
end)
|
||||
|
||||
local scanner = libtipscan:GetScanner("prediction")
|
||||
hooksecurefunc("UseAction", function(slot, target, selfcast)
|
||||
@@ -325,7 +325,7 @@ hooksecurefunc("UseAction", function(slot, target, selfcast)
|
||||
spell_queue[1] = effect
|
||||
spell_queue[2] = effect.. ( rank or "" )
|
||||
spell_queue[3] = selfcast and UnitName("player") or UnitName("target") and UnitCanAssist("player", "target") and UnitName("target") or UnitName("player")
|
||||
end, true)
|
||||
end)
|
||||
|
||||
libpredict.sender = CreateFrame("Frame", "ShaguTweaksPredictionSender", UIParent)
|
||||
libpredict.sender.enabled = true
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
local _G = ShaguTweaks.GetGlobalEnv()
|
||||
local GetExpansion = ShaguTweaks.GetExpansion
|
||||
local libtipscan = ShaguTweaks.libtipscan
|
||||
local hooksecurefunc = ShaguTweaks.hooksecurefunc
|
||||
|
||||
local scanner = libtipscan:GetScanner("libspell")
|
||||
local libspell = {}
|
||||
|
||||
@@ -2,7 +2,6 @@ local _G = ShaguTweaks.GetGlobalEnv()
|
||||
local T = ShaguTweaks.T
|
||||
local gfind = string.gmatch or string.gfind
|
||||
local GetUnitData = ShaguTweaks.GetUnitData
|
||||
local hooksecurefunc = ShaguTweaks.hooksecurefunc
|
||||
local GetExpansion = ShaguTweaks.GetExpansion
|
||||
local cmatch = ShaguTweaks.cmatch
|
||||
local rgbhex = ShaguTweaks.rgbhex
|
||||
|
||||
@@ -110,7 +110,7 @@ module.enable = function(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
end, true)
|
||||
end)
|
||||
end
|
||||
|
||||
do -- add colors to friend list
|
||||
@@ -168,7 +168,7 @@ module.enable = function(self)
|
||||
friendInfo:SetVertexColor(1,1,1,.4)
|
||||
end
|
||||
end
|
||||
end, true)
|
||||
end)
|
||||
end
|
||||
|
||||
do -- add colors to who list
|
||||
@@ -226,6 +226,6 @@ module.enable = function(self)
|
||||
local color = GetDifficultyColor(level)
|
||||
_G["WhoFrameButton"..i.."Level"]:SetTextColor(color.r, color.g, color.b)
|
||||
end
|
||||
end, true)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user