-
Notifications
You must be signed in to change notification settings - Fork 91
Tag examples
As all the tags are done with pure Lua, they are fairly straight forward, as of r20090616 SUF now will attempt to automatically detect what events your tag will need to make them even easier to setup, if you run into any issues with creating a tag feel free to post it any of the SUF topics on WoWInterface/Curse/Elitist Jerks and I will get back to you on how to fix it.
Keep in mind that when you use a color code, you must close it or it will spread over to other text.
Textures can be embedded into tags by using |T<texture>:<height>:<width>:<x offset>:<y offset>|t
, for example doing |TInterface\\Icons\\INV_EssenceOfWintergrasp:26:26:0:0|t
will create an icon with a height/width of 26 using the Wintergrasp icon, if you leave the height/width at 0 then the icon will automatically be sized based on the font size.
The variable unit refers to the current unit that is shown on the unit frame, for example if the player is currently inside a vehicle (and they do not have vehicle swapping disabled) then the unit will be vehicle. However, he variable unitOwner refers to the original unit, meaning that for the player this will always be player even if they are in a vehicle..
The reason for this distinction is to allow you to choose which unit you want data for, if you’re making a tag to show the units name then you will probably want to use unitOwner instead of unit so you can keep showing the original players name instead of the vehicles.
If the unit has quick health or power enabled, SUF will automatically update your tag faster to reflect the quick updates, you do not need to do any special calls to do this.
Here’s a good example of when to use unit vs unitOwner, if you want to make a tag so that it shortens names that are too long, but you want to show the actual unit and not their vehicle (If they are in one) you will use unitOwner
The reason string.sub is used in this tag is because it lets you choose which part of text you want to keep, in this case 0, 10 indicates that it should keep the first 10 characters, so if someone is named Reallylongname you will only see Reallylong. This also is a good use of when to use unitOwner instead of unit, if Reallylongname is in the vehicle Salvaged Siege Engine using unitOwner ensures that you still see Reallylongname as the name in the frame.
function(unit, unitOwner)
return string.sub((UnitName(unitOwner)), 0, 10)
end
Here’s a basic example of showing a certain text if the unit has either Faerie Fire or Faerie Fire (Feral) on them.
function(unit, unitOwner)
-- Return "FF" in pink if the unit has Faerie Fire or Faerie Fire Feral on them
if( UnitDebuff(unit, "Faerie Fire") or UnitDebuff(unit, "Faerie Fire (Feral)") ) then
return string.format("%sFF|r", ShadowUF:Hex(0.85, 0.15, 0.80))
end
end
Another example of showing that a unit is missing Prayer of Fortitude (and doesn’t have Power Word: Fortitude) as well as Prayer of Shadow Protection (and doesn’t have Shadow Protection)
function(unit, unitOwner)
-- Return "PoF" in light green if the unit does not have Prayer of Fortitude or Power Word: Fortitude
if( not UnitBuff(unit, "Prayer of Fortitude") and not Unitbuff(unit, "Power Word: Fortitude") ) then
return string.format("%sPoF|r", ShadowUF:Hex(0.40, 0.77, 0.37))
end
-- Return "PoS" in dark purple if the unit does not have Prayer of Shadow Protection or Shadow Protection
-- This is an example of just returning the hex code instead of using ShadowUF:Hex to get it.
if( not UnitBuff(unit, "Prayer of Fortitude") and not Unitbuff(unit, "Shadow Protection") ) then
return "|cff4c4c7fPoF|r"
end
end
This is one of the easier tags to create, one that shows the units current health/maximum health or Dead/Ghost/Offline.
function(unit, unitOwner)
-- Unit is dead, but they haven't released yet
if( UnitIsDead(unit) ) then
return ShadowUFLocals["Dead"]
-- Unit is dead, and they have released
elseif( UnitIsGhost(unit) ) then
return ShadowUFLocals["Ghost"]
-- Unit is no longer online
elseif( not UnitIsConnected(unit) ) then
return ShadowUFLocals["Offline"]
end
-- Unit is alive and well, will use UnitHealth to get their current health, and UnitHealthMax to get their maximum health.
-- using / as a separate will make it show current/max in the tag.
local health = UnitHealth(unit)
local maxHealth = UnitHealthMax(unit)
return string.format("%s/%s", health, maxHealth)
end
If you wanted to make the same tag, but with short formatting so it would use 10k instead of 10,000 and so on, you would use the below.
function(unit, unitOriginal)
-- Unit is dead, but they haven't released yet
if( UnitIsDead(unit) ) then
return ShadowUFLocals["Dead"]
-- Unit is dead, and they have released
elseif( UnitIsGhost(unit) ) then
return ShadowUFLocals["Ghost"]
-- Unit is no longer online
elseif( not UnitIsConnected(unit) ) then
return ShadowUFLocals["Offline"]
end
-- Unit is alive and well, will use UnitHealth to get their current health, and UnitHealthMax to get their maximum health.
-- using / as a separate will make it show current/max in the tag.
local health = ShadowUF:FormatLargeNumber(UnitHealth(unit))
local maxHealth = ShadowUF:FormatLargeNumber(UnitHealthMax(unit))
return string.format("%s/%s", health, maxHealth)
end
This is how you would create a tag that will return a colored class name if they are a player, but return the mob type otherwise.
function(unit, unitOwner)
-- Check if they are a player
if( not UnitIsPlayer(unit) ) then
-- Not a player, return the mob type, anything from Wolf to Succubus
return UnitCreatureFamily(unit)
end
-- They are a player, meaning we shouldn't have any issues getting their class, try and find the class color
local classColor = ShadowUF:GetClassColor(unit)
-- Couldn't find the class color, revert to returning the class name without any coloring
if( not classColor ) then
-- You must return nil instead of "" because this tells SUF that there is nothing inside the tag and it doesn't have to do any prefix or suffixes to it.
return nil
end
-- Got the class color, return the name with coloring! Keep in mind the |r in this, this tells the text that it only wants the class coloring around the class name and nowhere else.
return string.format("%s%s|r", classColor, UnitClass(unit))
end