From b373360ae8aad5cd9135abcb819fb042bc0814ae Mon Sep 17 00:00:00 2001 From: Spit <19otari98@gmail.com> Date: Tue, 18 Mar 2025 12:29:36 +0300 Subject: [PATCH] auto-stance: reduce clicks needed to switch stance --- mods/auto-stance.lua | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/mods/auto-stance.lua b/mods/auto-stance.lua index fc936b3..ec42dd9 100644 --- a/mods/auto-stance.lua +++ b/mods/auto-stance.lua @@ -10,37 +10,14 @@ local module = ShaguTweaks:register({ }) module.enable = function(self) - local stancedance = CreateFrame("Frame") - stancedance:RegisterEvent("UI_ERROR_MESSAGE") - stancedance:SetScript("OnEvent", function() stancedance.lastError = arg1 end) - - stancedance.lastError = "" + local stancedance = CreateFrame("Frame", "ShaguTweaksStancedance") stancedance.scanString = string.gsub(SPELL_FAILED_ONLY_SHAPESHIFT, "%%s", "(.+)") - stancedance.CastSpell = CastSpell - stancedance.CastSpellByName = CastSpellByName - stancedance.UseAction = UseAction - - stancedance.SwitchStance = function() - for stance in string.gfind(stancedance.lastError, stancedance.scanString) do - for _, stance in pairs({ strsplit(",", stance)}) do - stancedance.CastSpellByName(string.gsub(stance,"^%s*(.-)%s*$", "%1")) + stancedance:RegisterEvent("UI_ERROR_MESSAGE") + stancedance:SetScript("OnEvent", function() + for stances in string.gfind(arg1, stancedance.scanString) do + for _, stance in pairs({ strsplit(",", stances)}) do + CastSpellByName(string.gsub(stance,"^%s*(.-)%s*$", "%1")) end end - stancedance.lastError = "" - end - - function CastSpell(spellId, spellbookTabNum) - stancedance:SwitchStance() - stancedance.CastSpell(spellId, spellbookTabNum) - end - - function CastSpellByName(spellName, onSelf) - stancedance:SwitchStance() - stancedance.CastSpellByName(spellName, onSelf) - end - - function UseAction(slot, checkCursor, onSelf) - stancedance:SwitchStance() - stancedance.UseAction(slot, checkCursor, onSelf) - end + end) end