I use /run SetRaidTarget("target",8)
in a targeting macro. Each time it’s run (without changing targets) the display of the icon toggles. Can this be avoided?
https://warcraft.wiki.gg/wiki/API_GetRaidTargetIndex
/run if GetRaidTargetIndex("target") ~= 8 then SetRaidTarget("target",8) end
Lovely, thanks a bunch.
This is a frustrating bug I just hit.
Blizzard needs to fix it!
/SetRaidTargetIcon is supposed to toggle, and /SetRaidTarget is NOT, yet it acts exactly like /SetRaidTargetIcon.
It’s easy to see the bug.
If you type /script SetRaidTarget(“focus”,5) in the chat, and watch your moon icon appear on your focus, then you repeat the chat, it toggles off, and will continue to toggle every time you repeat.
It’s not working at all. It is basically the same as SetRaidTargetIcon.
That might work for some as a work-around to the bug, but it doesn’t work for me, because you can’t do an if else.
Also, it increases macro length a lot, so I really hope Blizzard fixes it.
It’s working as intended:
This API toggles the icon if it’s already assigned to the unit.
https://warcraft.wiki.gg/wiki/API_SetRaidTarget
Yes you can.
That’s the problem I mentioned above, except it is NOT supposed to toggle, that’s what SetRaidTargetIcon does. SetRaidTarget is NOT supposed to toggle.
It is supposed to toggle.
If you look it up, SetRaidTargetIcon is supposed to toggle, and SetRaidTarget is NOT.
They are acting like the same thing.
Here’s the problem, I do NOT want it to toggle, if it’s already set.
/run if IsShiftKeyDown() then SetRaidTarget(“focus”,0) else SetRaidTarget(“focus”,5) end
Since there seems to be no way to do an else if, I can’t get it to work.
I tried this, but no luck:
/run if IsShiftKeyDown() then SetRaidTarget(“focus”,0); else if GetRaidTargetIndex(“focus”)~=5 then SetRaidTarget(“focus”,5) end
If the function worked as described in the manuals, and did not toggle, then the first shorter and simpler example would work.
They are 2 different functions. the “icon” one is supposed to toggle, the other is not.
I am trying to figure out another way.
Any thoughts?
Thanks
oh, I did try two separate /run lines, but it seems that only one can work in a macro.
This is where you’re going to find the most up to date info on the API function:
https://warcraft.wiki.gg/wiki/API_SetRaidTarget
That page states:
This API toggles the icon if it’s already assigned to the unit.
As for the else if, your syntax is wrong.
https://www.lua.org/pil/4.3.1.html
Use the following
/run if IsShiftKeyDown() then SetRaidTarget("focus",0) elseif GetRaidTargetIndex("focus")~=5 then SetRaidTarget("focus",5) end
I recommend you grab BugSack and BugGrabber for debugging.
Even the initial warcraft wiki page that hasn’t seen an update in 12 years says it toggles
I must have been looking at a really old page. I did find this update, where they actually crossed out the note on toggle.
“SetRaidTarget is the native API function used (and does not exhibit the toggling behavior)”
wowpedia fandom com wiki API_SetRaidTargetIcon
Thanks.
I finally got it working in an insane way, but with what you have above, I am going to try to shorten it…
I got it working better with your help. thanks!
Here’s what I did, with the old one below that was my WIP.
/focus [@focus,noexists,noharm,nodead]
/cast [nomod,@focus,exists,harm,nodead]Fear
/run if IsShiftKeyDown() then SetRaidTarget(“focus”,0) elseif GetRaidTargetIndex(“focus”)~=5 then SetRaidTarget(“focus”,5) end
/clearfocus [mod:shift]
old
/focus [@focus,noexists,noharm,nodead]
/cast [nomod,@focus,exists,harm,nodead]Fear
/run c=IsShiftKeyDown() d=GetRaidTargetIndex(“focus”) if (not c and d~=5) then SetRaidTarget(“focus”,5) else if c then SetRaidTarget(“focus”,0) end end
/clearfocus [mod]