Thread Tools Display Modes
02-29-24, 12:33 PM   #1
Kovexpulthul
A Defias Bandit
Join Date: Feb 2024
Posts: 2
Script/Code to track Player buff as icon

Is it possible for anyone here to write a script for me that I can then make into an addon.
I want to track a SINGLE buff on myself called Slice and Dice. However I want it to be tracked as Slice and Dice icon that would display next to my PlayerFrame (just like a WeakAura, but without using WeakAura, just with a script).
 
02-29-24, 02:02 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,913
That reminds me of one of my first addons back in the old Burning Crusade days when I was mage tanking Krosh Firehand. Wrote an addon to track the shield buff on him so I could steal it rofl.

I also did one more recently ( several expansions back ) where I watched for power shield on my priest. Or something similar.

Neither addon would work now ( if I still had the code somewhere ) unfortunately but could be a good starting point.

I'll monitor the post to see if you get any joy.
__________________
 
02-29-24, 04:48 PM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,876
It's a bit of a loaded question as it's missing details (most of which probably come with WeakAuras). You could start with something like:

Lua Code:
  1. local spellID, SnDID = 315496 -- S&D
  2. local _, _, icon = GetSpellInfo(spellID)
  3.  
  4. local f = CreateFrame("Frame", "Kovexpulthul_Buff", PlayerFrame, "AuraButtonArtTemplate")
  5. f:Hide()
  6. f:SetSize(40, 40)
  7. f.Icon:SetTexture(icon)
  8. f:SetPoint("RIGHT", PlayerFrame, "LEFT", 0, 0)
  9. f:RegisterEvent("UNIT_AURA")
  10. f:SetScript("OnEvent", function(self, event, ...)
  11.     local unit, auraInfo = ...
  12.     local added, updated, removed, full = auraInfo.addedAuras, auraInfo.updatedAuraInstanceIDs, auraInfo.removedAuraInstanceIDs, auraInfo.isFullUpdate
  13.     if added then
  14.         for k, v in pairs(added) do
  15.             if v.spellId == spellID then
  16.                 SnDID = v.auraInstanceID
  17.                 self:Show()
  18.                 break
  19.             end
  20.         end
  21.     end
  22.     if removed then
  23.         for k, id in pairs(removed) do
  24.             if id == SnDID then
  25.                 SnDID = nil
  26.                 self:Hide()
  27.                 break
  28.             end
  29.         end
  30.     end
  31. end)

It's been a while since I looked at auras so there may well be a better way.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 02-29-24 at 05:02 PM.
 
02-29-24, 11:38 PM   #4
Kovexpulthul
A Defias Bandit
Join Date: Feb 2024
Posts: 2
Originally Posted by Xrystal View Post
That reminds me of one of my first addons back in the old Burning Crusade days when I was mage tanking Krosh Firehand. Wrote an addon to track the shield buff on him so I could steal it rofl.

I also did one more recently ( several expansions back ) where I watched for power shield on my priest. Or something similar.

Neither addon would work now ( if I still had the code somewhere ) unfortunately but could be a good starting point.

I'll monitor the post to see if you get any joy.
Forgot to mention this is to work on a private server 3.3.5 Wotlk so maybe it would work?

I want it to look like this combat indicator, next to my player frame just tracking how much SnD I have left:


Originally Posted by Fizzlemizz View Post
It's a bit of a loaded question as it's missing details (most of which probably come with WeakAuras). You could start with something like:

Lua Code:
  1. local spellID, SnDID = 315496 -- S&D
  2. local _, _, icon = GetSpellInfo(spellID)
  3.  
  4. local f = CreateFrame("Frame", "Kovexpulthul_Buff", PlayerFrame, "AuraButtonArtTemplate")
  5. f:Hide()
  6. f:SetSize(40, 40)
  7. f.Icon:SetTexture(icon)
  8. f:SetPoint("RIGHT", PlayerFrame, "LEFT", 0, 0)
  9. f:RegisterEvent("UNIT_AURA")
  10. f:SetScript("OnEvent", function(self, event, ...)
  11.     local unit, auraInfo = ...
  12.     local added, updated, removed, full = auraInfo.addedAuras, auraInfo.updatedAuraInstanceIDs, auraInfo.removedAuraInstanceIDs, auraInfo.isFullUpdate
  13.     if added then
  14.         for k, v in pairs(added) do
  15.             if v.spellId == spellID then
  16.                 SnDID = v.auraInstanceID
  17.                 self:Show()
  18.                 break
  19.             end
  20.         end
  21.     end
  22.     if removed then
  23.         for k, id in pairs(removed) do
  24.             if id == SnDID then
  25.                 SnDID = nil
  26.                 self:Hide()
  27.                 break
  28.             end
  29.         end
  30.     end
  31. end)

It's been a while since I looked at auras so there may well be a better way.
It doesn't seem to work. I changed spellID to correct one (6774, because I forgot to mention this is to work on private server on 3.3.5 patch) and it doesn't work, doesn't show anything
 
03-01-24, 01:24 AM   #5
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,913
Unfortunately we are unable to assist with private servers, only official wow versions.
__________________
 

WoWInterface » Developer Discussions » Lua/XML Help » Script/Code to track Player buff as icon

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off