Add minimal modern ClassicAPI macro aliases
This commit is contained in:
@@ -163,11 +163,21 @@ macro slots again for every button.
|
|||||||
|
|
||||||
#### Macro Tweaks — fixed / ClassicAPI-aware
|
#### Macro Tweaks — fixed / ClassicAPI-aware
|
||||||
|
|
||||||
Registers modern-style `/startattack` and `/stopattack` slash commands on
|
Registers a deliberately small set of modern-style slash commands backed by
|
||||||
Vanilla and routes them to ClassicAPI's non-toggling `StartAttack()` and
|
ClassicAPI:
|
||||||
`StopAttack()` functions. This avoids Vanilla treating `/startattack` as an
|
|
||||||
unknown slash command and, unlike `AttackTarget()`, repeated use cannot toggle
|
- `/startattack [unit]` → `StartAttack(unit)`
|
||||||
an active auto-attack off.
|
- `/stopattack` → `StopAttack()`
|
||||||
|
- `/focus [unit]` → `FocusUnit(unit)` (defaults to current target)
|
||||||
|
- `/clearfocus` → `ClearFocus()`
|
||||||
|
|
||||||
|
Each alias is only registered when another addon has not already claimed the
|
||||||
|
same command. This keeps Macro Tweaks a compatibility/convenience layer rather
|
||||||
|
than duplicating ClassicAPI itself.
|
||||||
|
|
||||||
|
No `/castnotoggle` alias is added: ClassicAPI already recognizes
|
||||||
|
`CastSpellNoToggle("Spell")` directly inside macro bodies and tags the action
|
||||||
|
slot correctly, so an extra slash command would be redundant.
|
||||||
|
|
||||||
Container item lookup now prefers ClassicAPI item IDs/names.
|
Container item lookup now prefers ClassicAPI item IDs/names.
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ versions already exist in ShaguTweaks-ClassicAPI:
|
|||||||
### Macro
|
### Macro
|
||||||
- Macro Icons
|
- Macro Icons
|
||||||
- Macro Tweaks
|
- Macro Tweaks
|
||||||
|
- modern ClassicAPI aliases: `/startattack`, `/stopattack`, `/focus`, `/clearfocus`
|
||||||
|
|
||||||
### Raid
|
### Raid
|
||||||
- Enable Raid Frames
|
- Enable Raid Frames
|
||||||
|
|||||||
+44
-19
@@ -4,7 +4,7 @@ local API = ShaguTweaks.API or {}
|
|||||||
|
|
||||||
local module = ShaguTweaks:register({
|
local module = ShaguTweaks:register({
|
||||||
title = T["Macro Tweaks"],
|
title = T["Macro Tweaks"],
|
||||||
description = T["Add /equip, /use, /startattack and /stopattack to macros, remove #showtooltip from chat and hide macro commands from history."],
|
description = T["Add /equip, /use and modern ClassicAPI macro commands, remove #showtooltip from chat and hide macro commands from history."],
|
||||||
expansions = { ["vanilla"] = true, ["tbc"] = false },
|
expansions = { ["vanilla"] = true, ["tbc"] = false },
|
||||||
maintainer = "@shagu (GitHub)",
|
maintainer = "@shagu (GitHub)",
|
||||||
category = T["Macro"],
|
category = T["Macro"],
|
||||||
@@ -32,6 +32,8 @@ module.enable = function(self)
|
|||||||
if string.find(text, "^/cast%s*") then return end
|
if string.find(text, "^/cast%s*") then return end
|
||||||
if string.find(text, "^/startattack%s*") then return end
|
if string.find(text, "^/startattack%s*") then return end
|
||||||
if string.find(text, "^/stopattack%s*") then return end
|
if string.find(text, "^/stopattack%s*") then return end
|
||||||
|
if string.find(text, "^/focus%s*") then return end
|
||||||
|
if string.find(text, "^/clearfocus%s*") then return end
|
||||||
end
|
end
|
||||||
ChatFrameEditBox._AddHistoryLine(self, text)
|
ChatFrameEditBox._AddHistoryLine(self, text)
|
||||||
end
|
end
|
||||||
@@ -69,26 +71,49 @@ module.enable = function(self)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ClassicAPI exposes the modern non-toggling StartAttack/StopAttack verbs.
|
-- ClassicAPI exposes several modern macro primitives as Lua functions but
|
||||||
-- Register the corresponding slash commands so Vanilla's macro parser can
|
-- Vanilla does not register their familiar slash-command equivalents.
|
||||||
-- use the familiar modern syntax without falling through to "unknown command".
|
-- Add only the small set that maps cleanly to modern macro syntax, and leave
|
||||||
_G.SLASH_STARTATTACK1 = "/startattack"
|
-- any command already registered by another addon untouched.
|
||||||
_G.SlashCmdList.STARTATTACK = function(msg)
|
local function TrimUnit(msg)
|
||||||
if type(_G.StartAttack) ~= "function" then return end
|
if not msg then return nil end
|
||||||
|
local _, _, unit = string.find(msg, "^%s*(.-)%s*$")
|
||||||
local unit
|
return unit ~= "" and unit or nil
|
||||||
if msg then
|
|
||||||
_, _, unit = string.find(msg, "^%s*(.-)%s*$")
|
|
||||||
if unit == "" then unit = nil end
|
|
||||||
end
|
|
||||||
|
|
||||||
_G.StartAttack(unit)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
_G.SLASH_STOPATTACK1 = "/stopattack"
|
if not _G.SlashCmdList.STARTATTACK then
|
||||||
_G.SlashCmdList.STOPATTACK = function()
|
_G.SLASH_STARTATTACK1 = "/startattack"
|
||||||
if type(_G.StopAttack) == "function" then
|
_G.SlashCmdList.STARTATTACK = function(msg)
|
||||||
_G.StopAttack()
|
if type(_G.StartAttack) == "function" then
|
||||||
|
_G.StartAttack(TrimUnit(msg))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not _G.SlashCmdList.STOPATTACK then
|
||||||
|
_G.SLASH_STOPATTACK1 = "/stopattack"
|
||||||
|
_G.SlashCmdList.STOPATTACK = function()
|
||||||
|
if type(_G.StopAttack) == "function" then
|
||||||
|
_G.StopAttack()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not _G.SlashCmdList.FOCUS then
|
||||||
|
_G.SLASH_FOCUS1 = "/focus"
|
||||||
|
_G.SlashCmdList.FOCUS = function(msg)
|
||||||
|
if type(_G.FocusUnit) == "function" then
|
||||||
|
_G.FocusUnit(TrimUnit(msg))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not _G.SlashCmdList.CLEARFOCUS then
|
||||||
|
_G.SLASH_CLEARFOCUS1 = "/clearfocus"
|
||||||
|
_G.SlashCmdList.CLEARFOCUS = function()
|
||||||
|
if type(_G.ClearFocus) == "function" then
|
||||||
|
_G.ClearFocus()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user