Closed Moetsukii closed 12 months ago
Note to self:
https://wowwiki.fandom.com/wiki/API_GetPlayerBuff
Has conflicting documentation. Index 1..16 but in the example 0 is used for first index.
pfUI uses CancelPlayerBuff(GetPlayerBuff(-1 + i,"HELPFUL"))
But when I try to use it in combination with UnitBuff("player", i)
the Indices don't match when according to API docs they should.
Need to investigate further.
I'm still confused about UnitBuff
indexing. It didn't follow any logical indexing rules.
Oh well, it doesn't matter anymore.
@DennisWG I think you can close Issue #33 and #35 now
Hey,
thank you once again for contributing! I'm not too sure about this yet, though. I think that it would be confusing to some people to enter the icon's path instead of just the buff's name. Especially since the [no]buff modifier exists and does just that. Have you looked into Roids.HasBuffName and how I get the name there?
Since you've mentioned having troubles with some of the API functions, I've played around with this for a few minutes and got something working. Here's what I've done:
We also return the buff's index from Roids.HasBuffName
function Roids.HasBuffName(buffName, unit)
if not buffName or not unit then
return false;
end
local text = getglobal(RoidsTooltip:GetName().."TextLeft1");
for i=1, 32 do
RoidsTooltip:SetOwner(UIParent, "ANCHOR_NONE");
RoidsTooltip:SetUnitBuff(unit, i);
name = text:GetText();
RoidsTooltip:Hide();
buffName = string.gsub(buffName, "_", " ");
if ( name and string.find(name, buffName) ) then
return true;
return true, i; end end
return false; end
We can then simplify your action callback inside Roids.DoCancelAura
to just
function Roids.DoCancelAura(msg)
local handled;
local action = function(q)
for i=0,40 do
local icon = GetPlayerBuffTexture(i)
if icon then
if icon == q then
CancelPlayerBuff(GetPlayerBuff(i,"HELPFUL"))
break;
end
end
end
end
local action = function(buffName)
local found, index = Roids.HasBuffName(buffName, "player");
if not found then
return;
end
CancelPlayerBuff(GetPlayerBuff(index - 1, "HELPFUL"));
end
for k, v in pairs(Roids.splitString(msg, ";%s*")) do handled = false; if Roids.DoWithConditionals(v, action, nil, false, action) then handled = true; break; end end
return handled; end
From what I've been able to test so far this seems to work (including invisible GM buffs), but I'm no longer actively playing, so there may be some edge cases that I'm missing.
I think it would be very nice to support buff names, so could you give this a shot yourself and report back to me if this works for your tests as well?
Cheers, Dennis
Hello. /cast [nomod] spell doesne't work for me and
What is the right way to use them?
@DennisWG How do you wanna go about /cancelaura?
An easy way would be to include something like this: GetSpellInfoVanillaDB
To have a mapping between Icon <=> Spell Name.
But it's a 4MB file .....