From 8a97fa849c35db78a10b7060e97945f95697616a Mon Sep 17 00:00:00 2001 From: Jrc13245 Date: Mon, 15 Dec 2025 08:34:57 -0500 Subject: [PATCH] fix stopmacro usability broken due to removal of nampower handling --- Compatibility/SuperMacro.lua | 27 +++++++++++++++++++-------- Core.lua | 18 +++++++++++++++++- Init.lua | 3 +++ 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/Compatibility/SuperMacro.lua b/Compatibility/SuperMacro.lua index 929e964..d82eccb 100644 --- a/Compatibility/SuperMacro.lua +++ b/Compatibility/SuperMacro.lua @@ -19,7 +19,7 @@ do -- naturally via SuperMacro_RunMacro. This avoids conflicts with SuperMacro's keybinding system. local INTERCEPT = { cast=true, castsequence=true, use=true, - startattack=true, stopattack=true, stopcasting=true, + startattack=true, stopattack=true, stopcasting=true, stopmacro=true, target=true, retarget=true, cancelaura=true, unbuff=true, unqueue=true, unshift=true, equip=true, equipmh=true, equipoh=true, -- runmacro intentionally NOT included - see note above @@ -62,6 +62,11 @@ do CRM.Hooks.RunLine = CRM.Hooks.RunLine or orig_RunLine _G.RunLine = function(...) + -- Check stopmacro flag before processing any line + if CRM.stopMacroFlag then + return true -- Skip this line, tell SM we handled it + end + -- SuperMacro calls RunLine(line) one line at a time; handle first arg. local text = arg and arg[1] @@ -114,15 +119,21 @@ do CRM.SM_RunLineHooked = true - -- Redirect global RunMacro to SuperMacro_RunMacro so all macro execution - -- goes through RunLine (where our hook intercepts CRM commands). - -- This ensures both SuperMacro and CleveRoids features work together. + -- Hook SuperMacro_RunMacro to clear stopmacro flag at macro start + -- and redirect global RunMacro so all macro execution goes through RunLine if type(_G.SuperMacro_RunMacro) == "function" then - _G.RunMacro = function(index) - return _G.SuperMacro_RunMacro(index) + local orig_SuperMacro_RunMacro = _G.SuperMacro_RunMacro + CRM.Hooks.SuperMacro_RunMacro = orig_SuperMacro_RunMacro + + local function hooked_RunMacro(index) + -- Clear stopmacro flag at macro start + CRM.stopMacroFlag = false + return orig_SuperMacro_RunMacro(index) end - -- Also update the Macro alias - _G.Macro = _G.SuperMacro_RunMacro + + _G.SuperMacro_RunMacro = hooked_RunMacro + _G.RunMacro = hooked_RunMacro + _G.Macro = hooked_RunMacro end end diff --git a/Core.lua b/Core.lua index c445fb5..7462340 100644 --- a/Core.lua +++ b/Core.lua @@ -1217,11 +1217,21 @@ function CleveRoids.ExecuteMacroBody(body,inline) local lines = CleveRoids.splitString(body, "\n") if inline then lines = CleveRoids.splitString(body, "\\n"); end + -- Clear stopmacro flag at start of macro execution + CleveRoids.stopMacroFlag = false + if CleveRoids.macroRefDebug then CleveRoids.Print("|cff00ffff[MacroRef]|r ExecuteMacroBody called with " .. table.getn(lines) .. " lines") end for k,v in pairs(lines) do + -- Check stopmacro flag before each line + if CleveRoids.stopMacroFlag then + if CleveRoids.macroRefDebug then + CleveRoids.Print("|cffff8800[MacroRef]|r Stopped at line " .. k .. " due to /stopmacro") + end + break + end if CleveRoids.macroRefDebug then CleveRoids.Print("|cff88ff88[MacroRef]|r Executing line " .. k .. ": " .. string.sub(v, 1, 60)) end @@ -2091,7 +2101,8 @@ function CleveRoids.DoWithConditionals(msg, hook, fixEmptyTargetFunc, targetBefo end if action == "STOPMACRO" then - -- No-op: Nampower DLL handles spell queue timing natively + -- Set flag to stop subsequent lines in current macro + CleveRoids.stopMacroFlag = true return true end @@ -3639,6 +3650,11 @@ local function CRM_SM_InstallHook() } RunLine = function(...) + -- Check stopmacro flag before processing any line + if CleveRoids.stopMacroFlag then + return true -- Skip this line, tell SM we handled it + end + local text = (arg and arg[1]) or nil if type(text) == "string" then diff --git a/Init.lua b/Init.lua index 8c496f7..1dd448e 100644 --- a/Init.lua +++ b/Init.lua @@ -120,6 +120,9 @@ CleveRoids._originalArgsBuffer = {} CleveRoids.queuedSpell = nil CleveRoids.lastCastSpell = nil +-- Macro execution control +CleveRoids.stopMacroFlag = false + CleveRoids.ignoreKeywords = { action = true, ignoretooltip = true,