From 470ad3fd2409e966dfff690fc1855fa17190db3f Mon Sep 17 00:00:00 2001 From: Jrc13245 Date: Sat, 7 Mar 2026 16:34:26 -0500 Subject: [PATCH] fix cleartarget conditional --- Console.lua | 12 ++++++++++++ Core.lua | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Console.lua b/Console.lua index f1b761c..a0d8f2d 100644 --- a/Console.lua +++ b/Console.lua @@ -134,6 +134,18 @@ SlashCmdList.CLEARTARGET = ClearTarget -- HOOK DEFINITIONS START ---------------------------------- +-- /cleartarget hook +CleveRoids.Hooks.CLEARTARGET_SlashCmd = SlashCmdList.CLEARTARGET +SlashCmdList.CLEARTARGET = function(msg) + if CleveRoids.stopMacroFlag then return end + msg = msg or "" + if string.find(msg, "%[") then + CleveRoids.DoConditionalClearTarget(msg) + else + CleveRoids.Hooks.CLEARTARGET_SlashCmd() + end +end + -- /startattack hook CleveRoids.Hooks.STARTATTACK_SlashCmd = SlashCmdList.STARTATTACK SlashCmdList.STARTATTACK = function(msg) diff --git a/Core.lua b/Core.lua index 21278ce..880fc16 100644 --- a/Core.lua +++ b/Core.lua @@ -3036,6 +3036,24 @@ function CleveRoids.DoConditionalStopCasting(msg) return false end +local function _clearTargetAction() + ClearTarget() +end + +-- Attempts to conditionally clear target. Returns false if no conditionals are found. +function CleveRoids.DoConditionalClearTarget(msg) + if not string.find(msg, "%[") then return false end + + -- PERFORMANCE: Use numeric iteration to avoid pairs() iterator allocation + local parts = CleveRoids.splitStringIgnoringQuotes(msg) + for i = 1, table.getn(parts) do + if CleveRoids.DoWithConditionals(parts[i], nil, CleveRoids.FixEmptyTarget, false, _clearTargetAction) then + return true + end + end + return false +end + -- Attempts to use or equip an item by a set of conditionals -- Also checks if a condition is a spell so that you can mix item and spell use -- msg: The raw message intercepted from a /use or /equip command