API UnitBuff: Difference between revisions
>Basedturtle moved to api functions |
(No difference)
|
Latest revision as of 15:47, 19 October 2024
Retrieve info about a certain buff on a certain unit.
buffTexture, buffApplications = UnitBuff(unit, buffIndex, showCastable);
Arguments
- (String unit)
- unit
- String - The UnitId to select as a target.
- BuffIndex
- Number - The index num of the buff to retrieve info on. Starts at 1 and goes up to (and possibly beyond) a certain number. The maximum numbers used by turtle code are 32 for party/pet and 8(?) for target buffs.
- ShowCastable
- Boolean - Flag (optional) - Can be 0, 1, or nil. If present and 1, then only buffs will be returned which are castable by the player. Index is still starting with 1 and counting up.
Returns
BuffTexture
String - The identifier of (path and filename to) the indicated buff, or nil if no buff
BuffApplications
String - The number of times the buff has been applied to the target.
Example 1
Retrieve the buff texture of the pets buff with the index of "i".
buff = UnitBuff("pet", i);
Example 2
Uses BUFF if the main buff is active, or else uses SPELL
/run local i,x=1,0 while UnitBuff("player",i) do if UnitBuff("player",i)=="Interface\\Icons\\Spell_Texture_Name" then x=1 end i=i+1 end if x==0 then CastSpellByName("BUFF") else CastSpellByName("SPELL") end
You need to replace "BUFF_TEXTURE" with the TEXTURE of a particular buff and NOT it's name. For example A Rogue's Stealth skill and a Druid's Prowl skill both use the little icon texture called "Ability_Ambush". Use this site to lookup your buff's texture: Queriable_buff_effects
Example 3
This prints the texture names of any buffs and debuffs on the target
/run function m(s) DEFAULT_CHAT_FRAME:AddMessage(s); end for i=1,16 do s=UnitBuff("target", i); if(s) then m("B "..i..": "..s); end s=UnitDebuff("target", i); if(s) then m("D "..i..": "..s); end end