mirror of
https://github.com/brues-code/SuperCleveRoidMacros.git
synced 2026-09-16 03:38:00 +00:00
add support for 'button' conditional (#3)
* add support for 'button' conditional * Route [button] through Multi, add [nobutton], register as static - [button] now reads conditionals.button via Multi(...) instead of indexing _groups.button[1].values[1] directly, so OR/AND lists and repeated groups behave like every other argument conditional. [button:1/2] now matches left or right; previously only the first value was ever checked and the rest were silently dropped. This also removes the unguarded _groups reach-in, which Multi itself defends against (it checks _groups is present and falls back to _operators). - Adds [nobutton:N] via NegatedMulti, following the convention that every conditional ships its negation (nomod, nostance, nokeydown, ...). - Bare [button] / [nobutton] now mean "any / no mapped mouse button held", mirroring bare [mod]. Bare [nobutton] doubles as an "activated by a keybind rather than a click" test. - Registers button/nobutton in STATIC_CONDITIONALS next to mod and keydown, so they are checked once up front rather than re-evaluated for every candidate unit during multiscan target scanning. Still open: IsMouseButtonDown reports live physical state, so a keybound macro has no button held and [button:N] is false for it, and whether the button still reads down at macro-execution time depends on whether the action button fires on mouse-down or mouse-up. Needs in-game verification. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
This commit is contained in:
@@ -5422,6 +5422,30 @@ end
|
|||||||
|
|
||||||
-- A list of Conditionals and their functions to validate them
|
-- A list of Conditionals and their functions to validate them
|
||||||
CleveRoids.Keywords = {
|
CleveRoids.Keywords = {
|
||||||
|
-- [button:N] — true while mouse button N is held (1=Left, 2=Right, 3=Middle,
|
||||||
|
-- 4/5=extra). Routed through Multi so OR/AND lists and repeated groups behave
|
||||||
|
-- like every other argument conditional ([button:1/2] = left or right).
|
||||||
|
-- [button] with no argument — true if any mapped mouse button is held.
|
||||||
|
button = function(conditionals)
|
||||||
|
if type(conditionals.button) ~= "table" then
|
||||||
|
return CleveRoids.AnyMouseButtonDown()
|
||||||
|
end
|
||||||
|
return Multi(conditionals.button, function(button)
|
||||||
|
local name = CleveRoids.buttons[button]
|
||||||
|
return name and IsMouseButtonDown(name) or false
|
||||||
|
end, conditionals, "button")
|
||||||
|
end,
|
||||||
|
|
||||||
|
nobutton = function(conditionals)
|
||||||
|
if type(conditionals.nobutton) ~= "table" then
|
||||||
|
return not CleveRoids.AnyMouseButtonDown()
|
||||||
|
end
|
||||||
|
return NegatedMulti(conditionals.nobutton, function(button)
|
||||||
|
local name = CleveRoids.buttons[button]
|
||||||
|
return not (name and IsMouseButtonDown(name))
|
||||||
|
end, conditionals, "nobutton")
|
||||||
|
end,
|
||||||
|
|
||||||
exists = function(conditionals)
|
exists = function(conditionals)
|
||||||
return UnitExists(conditionals.target)
|
return UnitExists(conditionals.target)
|
||||||
end,
|
end,
|
||||||
@@ -9330,6 +9354,7 @@ CleveRoids.STATIC_CONDITIONALS = {
|
|||||||
inbag = true, noinbag = true,
|
inbag = true, noinbag = true,
|
||||||
mod = true, nomod = true,
|
mod = true, nomod = true,
|
||||||
keydown = true, nokeydown = true,
|
keydown = true, nokeydown = true,
|
||||||
|
button = true, nobutton = true,
|
||||||
swimming = true, noswimming = true, swim = true, noswim = true,
|
swimming = true, noswimming = true, swim = true, noswim = true,
|
||||||
indoors = true, noindoors = true, outdoors = true, nooutdoors = true,
|
indoors = true, noindoors = true, outdoors = true, nooutdoors = true,
|
||||||
rooted = true, norooted = true,
|
rooted = true, norooted = true,
|
||||||
|
|||||||
+18
@@ -656,6 +656,24 @@ function CleveRoids.PrintT(t, depth)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
CleveRoids.buttons = {
|
||||||
|
['1'] = 'LeftButton',
|
||||||
|
['2'] = 'RightButton',
|
||||||
|
['3'] = 'MiddleButton',
|
||||||
|
['4'] = 'Button4',
|
||||||
|
['5'] = 'Button5',
|
||||||
|
}
|
||||||
|
|
||||||
|
-- True while any mapped mouse button is held. Backs the argument-less [button] /
|
||||||
|
-- [nobutton], mirroring how a bare [mod] means "any modifier". Bare [nobutton] is
|
||||||
|
-- the practical "activated by a keybind, not a click" test.
|
||||||
|
function CleveRoids.AnyMouseButtonDown()
|
||||||
|
for _, name in pairs(CleveRoids.buttons) do
|
||||||
|
if IsMouseButtonDown(name) then return true end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
CleveRoids.kmods = {
|
CleveRoids.kmods = {
|
||||||
ctrl = IsControlKeyDown,
|
ctrl = IsControlKeyDown,
|
||||||
lctrl = IsLeftControlKeyDown,
|
lctrl = IsLeftControlKeyDown,
|
||||||
|
|||||||
Reference in New Issue
Block a user