From 7ecac458ac9363ec58009ebfb16d20f8df9eb82d Mon Sep 17 00:00:00 2001 From: shagu Date: Fri, 28 Sep 2018 22:53:16 +0200 Subject: [PATCH] api: use dynamic shortcut for string.gfind --- api/api.lua | 3 +++ api/tbc.lua | 3 +++ libs/libcast.lua | 20 ++++++++++---------- libs/libdebuff.lua | 6 +++--- modules/autoshift.lua | 2 +- modules/chat.lua | 2 +- modules/pixelperfect.lua | 2 +- modules/prediction.lua | 8 ++++---- 8 files changed, 26 insertions(+), 20 deletions(-) diff --git a/api/api.lua b/api/api.lua index 056cbd04..96d3059e 100644 --- a/api/api.lua +++ b/api/api.lua @@ -883,3 +883,6 @@ function pfUI.api.GetColorGradient(perc) gradientcolors[perc].b, gradientcolors[perc].h end + +-- [ shortcuts ] +pfUI.api.gfind = string.gfind diff --git a/api/tbc.lua b/api/tbc.lua index 41f943f0..683af8c5 100644 --- a/api/tbc.lua +++ b/api/tbc.lua @@ -8,6 +8,9 @@ setfenv(1, pfUI:GetEnvironment()) -- the "MiniMapTrackingFrame" is called "MiniMapTracking" pfUI.api.MiniMapTrackingFrame = _G.MiniMapTracking +-- gfind got replaced by gmatch +pfUI.api.gfind = string.gmatch + -- blacklist pfUI functions pfUI.api.hooksecurefunc = nil pfUI.api.select = nil diff --git a/libs/libcast.lua b/libs/libcast.lua index 0d9f6ca7..88f23af8 100644 --- a/libs/libcast.lua +++ b/libs/libcast.lua @@ -192,61 +192,61 @@ libcast:SetScript("OnEvent", function() -- Fill database with environmental casts elseif arg1 then -- (.+) begins to cast (.+). - for mob, spell in string.gfind(arg1, libcast.SPELL_CAST) do + for mob, spell in gfind(arg1, libcast.SPELL_CAST) do libcast:AddAction(mob, spell) return end -- (.+) begins to perform (.+). - for mob, spell in string.gfind(arg1, libcast.SPELL_PERFORM) do + for mob, spell in gfind(arg1, libcast.SPELL_PERFORM) do libcast:AddAction(mob, spell) return end -- (.+) gains (.+). - for mob, spell in string.gfind(arg1, libcast.SPELL_GAINS) do + for mob, spell in gfind(arg1, libcast.SPELL_GAINS) do libcast:RemoveAction(mob, spell) return end -- (.+) is afflicted by (.+). - for mob, spell in string.gfind(arg1, libcast.SPELL_AFFLICTED) do + for mob, spell in gfind(arg1, libcast.SPELL_AFFLICTED) do libcast:RemoveAction(mob, spell) return end -- Your (.+) hits (.+) for (%d+). - for spell, mob in string.gfind(arg1, libcast.SPELL_HIT) do + for spell, mob in gfind(arg1, libcast.SPELL_HIT) do libcast:RemoveAction(mob, spell) return end -- Your (.+) crits (.+) for (%d+). - for spell, mob in string.gfind(arg1, libcast.SPELL_CRIT) do + for spell, mob in gfind(arg1, libcast.SPELL_CRIT) do libcast:RemoveAction(mob, spell) return end -- (.+)'s (.+) %a hits (.+) for (%d+). - for _, spell, mob in string.gfind(arg1, libcast.OTHER_SPELL_HIT) do + for _, spell, mob in gfind(arg1, libcast.OTHER_SPELL_HIT) do libcast:RemoveAction(mob, spell) return end -- (.+)'s (.+) %a crits (.+) for (%d+). - for _, spell, mob in string.gfind(arg1, libcast.OTHER_SPELL_CRIT) do + for _, spell, mob in gfind(arg1, libcast.OTHER_SPELL_CRIT) do libcast:RemoveAction(mob, spell) return end -- You interrupt (.+)'s (.+)."; - for mob, spell in string.gfind(arg1, libcast.SPELL_INTERRUPT) do + for mob, spell in gfind(arg1, libcast.SPELL_INTERRUPT) do libcast:RemoveAction(mob, "INTERRUPT") return end -- (.+) interrupts (.+)'s (.+). - for _, mob, spell in string.gfind(arg1, libcast.OTHER_SPELL_INTERRUPT) do + for _, mob, spell in gfind(arg1, libcast.OTHER_SPELL_INTERRUPT) do libcast:RemoveAction(mob, "INTERRUPT") return end diff --git a/libs/libdebuff.lua b/libs/libdebuff.lua index 69e3b820..0eb7228e 100644 --- a/libs/libdebuff.lua +++ b/libs/libdebuff.lua @@ -179,7 +179,7 @@ libdebuff.pending = {} libdebuff:SetScript("OnEvent", function() -- Add Combat Log if event == "CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE" or event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE" then - for unit, effect in string.gfind(arg1, libdebuff.combatlog) do + for unit, effect in gfind(arg1, libdebuff.combatlog) do local unitlevel = UnitName("target") == unit and UnitLevel("target") or 0 if not libdebuff.objects[unit] or not libdebuff.objects[unit][unitlevel] or not libdebuff.objects[unit][unitlevel][effect] then @@ -203,7 +203,7 @@ libdebuff:SetScript("OnEvent", function() elseif event == "CHAT_MSG_SPELL_FAILED_LOCALPLAYER" or event == "CHAT_MSG_SPELL_SELF_DAMAGE" then -- Persist pending Spell for _, msg in pairs(libdebuff.pp) do - for effect, _ in string.gfind(arg1, msg) do + for effect, _ in gfind(arg1, msg) do libdebuff:PersistPending(effect) return end @@ -211,7 +211,7 @@ libdebuff:SetScript("OnEvent", function() -- Remove pending spell for _, msg in pairs(libdebuff.rp) do - for effect, _ in string.gfind(arg1, msg) do + for effect, _ in gfind(arg1, msg) do libdebuff:RemovePending(effect) return end diff --git a/modules/autoshift.lua b/modules/autoshift.lua index 44029866..5c76a95d 100644 --- a/modules/autoshift.lua +++ b/modules/autoshift.lua @@ -7,7 +7,7 @@ pfUI:RegisterModule("autoshift", function () pfUI.autoshift.scanString = string.gsub(SPELL_FAILED_ONLY_SHAPESHIFT, "%%s", "(.+)") function pfUI.autoshift:SwitchStance() - for stance in string.gfind(pfUI.autoshift.lastError, pfUI.autoshift.scanString) do + for stance in gfind(pfUI.autoshift.lastError, pfUI.autoshift.scanString) do for _, stance in pairs({ strsplit(",", stance)}) do pfUI.autoshift.CastSpellByName(string.gsub(stance,"^%s*(.-)%s*$", "%1")) end diff --git a/modules/chat.lua b/modules/chat.lua index aae2a938..3c584d80 100644 --- a/modules/chat.lua +++ b/modules/chat.lua @@ -858,7 +858,7 @@ pfUI:RegisterModule("chat", function () -- display class colors if already indexed if C.chat.text.classcolor == "1" then - for name in string.gfind(text, "|Hplayer:(.-)|h") do + for name in gfind(text, "|Hplayer:(.-)|h") do local color = unknowncolorhex local match = false -- search player in database diff --git a/modules/pixelperfect.lua b/modules/pixelperfect.lua index 44e4483f..03719bf6 100644 --- a/modules/pixelperfect.lua +++ b/modules/pixelperfect.lua @@ -16,7 +16,7 @@ pfUI:RegisterModule("pixelperfect", function () -- apply pixel dependent scaling local resolution = GetCVar("gxResolution") - for screenwidth, screenheight in string.gfind(resolution, "(.+)x(.+)") do + for screenwidth, screenheight in gfind(resolution, "(.+)x(.+)") do local screenheight = tonumber(screenheight) / 8 local scale = 768 / ( screenheight * conf ) diff --git a/modules/prediction.lua b/modules/prediction.lua index 25e053e0..e1376baa 100644 --- a/modules/prediction.lua +++ b/modules/prediction.lua @@ -278,25 +278,25 @@ pfUI:RegisterModule("prediction", function () pfUI.prediction.sender:SetScript("OnEvent", function() if event == "CHAT_MSG_SPELL_SELF_BUFF" then -- "Your %s heals %s for %d."; - for spell, _, heal in string.gfind(arg1, healedselfother) do + for spell, _, heal in gfind(arg1, healedselfother) do if spell == spell_queue[1] then cache[spell_queue[2]] = tonumber(heal) end return end -- "Your %s heals you for %d." - for spell, heal in string.gfind(arg1, healedselfself) do + for spell, heal in gfind(arg1, healedselfself) do if spell == spell_queue[1] then cache[spell_queue[2]] = tonumber(heal) end return end -- "Your %s critically heals %s for %d." - for spell, heal in string.gfind(arg1, healedcritselfother) do + for spell, heal in gfind(arg1, healedcritselfother) do if spell == spell_queue[1] and not cache[spell_queue[2]] then cache[spell_queue[2]] = tonumber(heal)*2/3 end return end -- "Your %s critically heals you for %d." - for spell, _, heal in string.gfind(arg1, healedcritselfself) do + for spell, _, heal in gfind(arg1, healedcritselfself) do if spell == spell_queue[1] and not cache[spell_queue[2]] then cache[spell_queue[2]] = tonumber(heal)*2/3 end return end