WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Script/Code to track Player buff as icon (https://www.wowinterface.com/forums/showthread.php?t=59809)

Kovexpulthul 02-29-24 12:33 PM

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).

Xrystal 02-29-24 02:02 PM

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.

Fizzlemizz 02-29-24 04:48 PM

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.

Kovexpulthul 02-29-24 11:38 PM

Quote:

Originally Posted by Xrystal (Post 343473)
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:


Quote:

Originally Posted by Fizzlemizz (Post 343474)
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 :(

Xrystal 03-01-24 01:24 AM

Unfortunately we are unable to assist with private servers, only official wow versions.


All times are GMT -6. The time now is 08:32 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI