Thread Tools Display Modes
07-24-18, 04:07 PM   #1
Lesteryoung
A Black Drake
Join Date: Aug 2015
Posts: 81
Help rectifying small batch of code 8.0 broke.

Hi, I've gathered small bits of code from this forum and the WoW forum over the years and 8.0 seems to have broken two bits of code. Would appreciate any help. I'm sure it's a simple fix.

Code 1:

Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("LOOT_OPENED")
  3. f:SetScript("OnEvent", function(self, event, ...)
  4.     for i = GetNumLootItems(), 1, -1 do
  5.         local slotType = GetLootSlotType(i)
  6.         local _, _, _, _, locked, isQuestItem = GetLootSlotInfo(i)
  7.         if not locked and (isQuestItem or slotType == LOOT_SLOT_MONEY or slotType == LOOT_SLOT_CURRENCY) then
  8.             LootSlot(i)
  9.         end
  10.     end
  11. end)

This just loots money on mobs.

Code 2:

Lua Code:
  1. hooksecurefunc("TargetFrame_UpdateAuras", function(s)
  2.           local name = s:GetName() .. "Buff"
  3.           for i = 1 ,MAX_TARGET_BUFFS do
  4.                local _, _, _, _, buffType = UnitAura(s.unit, i)
  5.                if buffType == 'Magic' then
  6.                     _G[name .. i .. "Stealable"]:Show()
  7.            end
  8.       end
  9. end)

This just shows the dispel effect around dispellable debuffs on any class/spec.

Both simply don't function since the patch.
  Reply With Quote
07-25-18, 04:09 AM   #2
Sylen
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 50
I use this for highlighting debuffs

Lua Code:
  1. --Highlight Purgable Magic Buffs on Target and Focus
  2. hooksecurefunc("TargetFrame_UpdateAuras", function(s)
  3.     for i = 1, MAX_TARGET_BUFFS do
  4.         _, ic, _, dT = UnitBuff(s.unit, i)
  5.         if(ic and (not s.maxBuffs or i<=s.maxBuffs)) then
  6.             fS=_G[s:GetName().."Buff"..i.."Stealable"]
  7.             if(UnitIsEnemy(PlayerFrame.unit, s.unit) and dT=="Magic") then
  8.                 fS:Show()
  9.             else
  10.                 fS:Hide()
  11.             end
  12.         end
  13.     end
  14. end)


With some classes getting a dispel for enrage effects back, might want to use this

Lua Code:
  1. --Highlight Purgable Enrage Buffs on Target and Focus
  2. --Enrage effects return an empty string as debuffType
  3. hooksecurefunc("TargetFrame_UpdateAuras", function(s)
  4.     for i = 1, MAX_TARGET_BUFFS do
  5.         _, ic, _, dT = UnitBuff(s.unit, i)
  6.         if(ic and (not s.maxBuffs or i<=s.maxBuffs)) then
  7.             fS=_G[s:GetName().."Buff"..i.."Stealable"]
  8.             if(UnitIsEnemy(PlayerFrame.unit, s.unit) and dT=="") then
  9.                 fS:Show()
  10.             else
  11.                 fS:Hide()
  12.             end
  13.         end
  14.     end
  15. end)
  Reply With Quote
07-25-18, 11:05 AM   #3
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
[quote=Sylen;328958]I use this for highlighting debuffs

Lua Code:
  1. _, ic, _, dT = UnitBuff(s.unit, i)


Unless you're declaring these elsewhere prefixed by "local" you're leaking variables into the global scope. There have been a few occasions where Blizzard has accidentally done this themselves, so AddOn code which also was doing this started causing problems by touching the global "_" variable in secure code.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
07-25-18, 11:28 AM   #4
Sylen
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 50
Thanks for pointing this out. I must have missed this one when re-writing my UI for BFA.
  Reply With Quote
07-25-18, 04:27 PM   #5
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
[quote=Torhal;328966]
Originally Posted by Sylen View Post
I use this for highlighting debuffs

Lua Code:
  1. _, ic, _, dT = UnitBuff(s.unit, i)


Unless you're declaring these elsewhere prefixed by "local" you're leaking variables into the global scope. There have been a few occasions where Blizzard has accidentally done this themselves, so AddOn code which also was doing this started causing problems by touching the global "_" variable in secure code.
Yeah, I noticed this same thing with nUI a few years back when it was mentioned in passing. So I added the change during one of the expansion updates.
__________________
  Reply With Quote
07-25-18, 10:45 PM   #6
Lesteryoung
A Black Drake
Join Date: Aug 2015
Posts: 81
Just as an update, I tested both of those bits of code individually in isolation, with no other addon(s)/code active. They were working fine pre pre-patch, so something in the API changed. Not sure how to go about finding that out.
  Reply With Quote
07-26-18, 04:35 AM   #7
PhoenixPower
A Defias Bandit
Join Date: Aug 2011
Posts: 3
It seems like GetLootSlotInfo changed.

7.3.5
Lua Code:
  1. texture, item, quantity, quality, locked, isQuestItem, questId, isActive = GetLootSlotInfo(slot);

8.0
Lua Code:
  1. texture, item, quantity, currencyID, quality, locked, isQuestItem, questId, isActive = GetLootSlotInfo(slot);

This should work.
Lua Code:
  1. local locked, isQuestItem = select(6, GetLootSlotInfo(i))

And for UnitAura they got rid of the 2nd return value (rank)

Last edited by PhoenixPower : 07-26-18 at 04:44 AM.
  Reply With Quote
07-26-18, 07:55 PM   #8
Lesteryoung
A Black Drake
Join Date: Aug 2015
Posts: 81
And for UnitAura they got rid of the 2nd return value (rank)
And how would I write that change into the aforementioned code? Just delete the second "_,"?
  Reply With Quote
07-27-18, 02:40 AM   #9
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,237
Originally Posted by Lesteryoung View Post
And how would I write that change into the aforementioned code? Just delete the second "_,"?
Yes. For all the APIs that have had a return value removed and not replaced, then all the other return values are shifted one position left.
Lua Code:
  1. -- OLD VERSION
  2. local name, rank, itemID, textureID = ExampleAPI()
  3.  
  4. -- NEW VERSION
  5. local name, itemID, textureID = ExampleAPI()
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help rectifying small batch of code 8.0 broke.

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