Quantcast
Trying to add support for a shield to an old addon - WoWInterface
Thread Tools Display Modes
01-14-19, 06:12 PM   #1
captainveet
A Defias Bandit
Join Date: Jan 2019
Posts: 3
Question Trying to add support for a shield to an old addon

Alright so, i have been trying for the past few hours, to find a way to make the mage "Blazing Barrier" spell compatible with this addon (AbsorbBar) but i don't exactly know what's the problem. I've never touched LUA before and just did coding in school for a year so that doesn't help. I've tried to test the original code and i always get an error.. It's either this : "attempt to call a nil value (global 'CreateFrame')" or that

"lua5.3: source_file.lua:4: attempt to call a nil value (global 'CreateFrame')
stack traceback:
source_file.lua:4: in main chunk
[C]: in ?.


Here's the code and i hope you guys can help me !



Lua Code:
  1. AbsorbBarConfig = {}
  2. AbsorbBar = {}
  3.  
  4. local AbsorbBarAddon = CreateFrame("Frame", "AbsorbBarAddon", UIParent)
  5.  
  6. local DefaultConfig = {}
  7. local RegisteredEvents = {}
  8. AbsorbBarAddon:SetScript("OnEvent", function (self, event, ...) if (RegisteredEvents[event]) then return RegisteredEvents[event](self, event, ...) end end)
  9.  
  10. local ORGINAL_AMOUNT = 0
  11. local CURRENT_AMOUNT = 0
  12. local REMOVED_AMOUNT = 0
  13.  
  14. local ORGINAL_AMOUNT2 = 0
  15. local CURRENT_AMOUNT2 = 0
  16.  
  17. local AbsorbBar_MyGUID =0;
  18. local AbsorbBarClass = "";
  19.  
  20. local AB_SS = 'Sacred Shield'
  21. local AB_SB = 'Shield Barrier';
  22. local AB_PWS = 'Power Word: Shield';
  23. local AB_DA = 'Divine Aegis';
  24. local AB_IB = 'Ice Barrier';
  25. local AB_MS = 'Mana Shield';
  26. local AB_MW = 'Mage Ward'
  27. local AB_BB = 'Blazing Barrier';
  28. local AB_SF = 'Sacrifice';
  29. local AB_SPS = 'Spirit Shell';
  30.  
  31.  
  32. local pattern = "[aA]bsorb%a* (%d+) [^d]?%a*%s?damage" ; -- [1]
  33. local mylocale;
  34.  
  35. local    IB_Current, IB_Total, MS_Current, MS_Total, MW_Current, MW_Total, BB_Current, BB_Total = 0,0,0,0,0,0,0,0     -- MAGE
  36. local     PWS_Current, PWS_Total, DA_Current, DA_Total, SPS_Current,SPS_tmp, SPS_Total = 0,0,0,0,0,0,0 -- PRIEST
  37. local   SB_Current,SB_Total = 0,0 --Warrior
  38. local   SS_Current,SS_Total = 0,0 --Paladin
  39.  
  40. function RegisteredEvents:ADDON_LOADED(event, addon, ...)
  41. local _
  42.      AbsorbBarClass,_  = UnitClass("player");
  43.     if (
  44.     AbsorbBarClass ~= "Priest" and
  45.     AbsorbBarClass ~= "Mage"  and
  46.     AbsorbBarClass ~= "Warlock" and
  47.     AbsorbBarClass ~= "Warrior" and
  48.     AbsorbBarClass ~= "Paladin"
  49.     ) then
  50.         return -- disable addon of other classes
  51.     end
  52.    
  53.     if (addon == "AbsorbBar") then
  54.         SLASH_ABAR1 = '/abar'
  55.         SlashCmdList["ABAR"] = function (msg, editbox)
  56.             AbsorbBar.SlashCmdHandler(msg, editbox)    
  57.         end
  58.  
  59.        
  60.         setmetatable(AbsorbBarConfig, {__index = DefaultConfig})
  61.  
  62.         AbsorbBarUI.CreateEnergyBar()
  63.         AbsorbBarUI.CreateConfigMenu()
  64.         print("AbsorbBar " .. GetAddOnMetadata("AbsorbBar","Version") .. " Loaded. /abar for options" )
  65.     end
  66. end
  67.  
  68. function RegisteredEvents:PLAYER_LOGIN(event)
  69. local _
  70.     AbsorbBarClass,_  = UnitClass("player");
  71.     if (
  72.     AbsorbBarClass ~= "Priest" and
  73.     AbsorbBarClass ~= "Mage" and
  74.     AbsorbBarClass ~= "Warlock" and
  75.     AbsorbBarClass ~= "Warrior" and
  76.     AbsorbBarClass ~= "Paladin"
  77.     ) then
  78.         return -- disable addon of other classes
  79.     end
  80.  
  81.      AbsorbBar_MyGUID = UnitGUID("player");
  82.     mylocale = GetLocale();
  83.     AbsorbBar.Lang();
  84.     --print(" UnitGUID " ..UnitGUID("player"))
  85.     AbsorbBar.UpdateBar()
  86.    
  87.     -- show config panel at load
  88.     --InterfaceOptionsFrame_OpenToCategory("AbsorbBar")
  89. end    
  90.  
  91. function RegisteredEvents:UNIT_AURA(arg1, arg2)
  92. --print ("---")
  93. --print (arg1) -- UNIT_AURA
  94. --print (arg2) -- Player
  95. local _
  96.     -- MAGE
  97.     if AbsorbBarClass == "Mage" and arg2 == "player" then
  98.  
  99.         _, _, _, _, _, _, _, _, _, _, _, _, _, _,IB_Current = UnitBuff("Player", AB_IB)
  100.         _, _, _, _, _, _, _, _, _, _, _, _, _, _,MS_Current = UnitBuff("Player", AB_MS)
  101.            
  102.         if  (IB_Current ~= nil ) then    -- ice bar
  103.             if (IB_Current >= IB_Total) then
  104.                 IB_Total = IB_Current    
  105.             end    
  106.         else
  107.             IB_Total = 0
  108.             IB_Current = 0
  109.         end
  110.         if  (MS_Current ~= nil ) then    --  mana shield
  111.             if (MS_Current >= MS_Total) then
  112.                 MS_Total = MS_Current    
  113.             end    
  114.         else
  115.             MS_Total = 0
  116.             MS_Current = 0
  117.         end
  118.         if  (MW_Current ~= nil ) then    --  mage ward
  119.             if (MW_Current >= MW_Total) then
  120.                 MW_Total = MW_Current
  121.             end                
  122.         else
  123.             MW_Total = 0
  124.             MW_Current = 0
  125.         end    
  126.         if  (BB_Current ~= nil ) then   -- Blazing barrier
  127.             if (BB_Current >= BB_Total) then
  128.                 BB_Total = BB_Current
  129.             end    
  130.         else
  131.             BB_Total = 0
  132.             BB_Current = 0
  133.         end
  134.        
  135.         CURRENT_AMOUNT2 = 0
  136.         ORGINAL_AMOUNT2 = 0
  137.         if IB_Total ~= nil and IB_Current ~= nil then
  138.             CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + IB_Current
  139.             ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + IB_Total
  140.         end
  141.         if MS_Total ~= nil and MS_Current ~= nil then
  142.             CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + MS_Current
  143.             ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + MS_Total
  144.         end
  145.         if MW_Total ~= nil and MW_Current ~= nil then
  146.             CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + MW_Current
  147.             ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + MW_Total
  148.         end
  149.         if BB_Total ~= nil and BB_Current ~= nil then
  150.             CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + BB_Current
  151.             ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + BB_Total
  152.         end
  153.         AbsorbBar.UpdateBar()
  154.         return
  155.     end
  156.    
  157.     -- PRIEST
  158.     if AbsorbBarClass == "Priest" and arg2 == "player"  then
  159.    
  160.         _, _, _, _, _, _, _, _, _, _, _, _, _, _,PWS_Current = UnitBuff("Player", AB_PWS)
  161.         _, _, _, _, _, _, _, _, _, _, _, _, _, _,DA_Current = UnitBuff("Player", AB_DA)
  162.        
  163.        
  164.         SPS_Current =getspiritshield()
  165.        
  166.         if  (PWS_Current ~= nil ) then    -- Power word shield
  167.             if (PWS_Current >= PWS_Total) then
  168.                 PWS_Total = PWS_Current    
  169.             end    
  170.         else
  171.             PWS_Total = 0
  172.             PWS_Current = 0
  173.         end
  174.         if  (DA_Current ~= nil ) then    --  Divine Aegis
  175.             if (DA_Current >= DA_Total) then
  176.                 DA_Total = DA_Current    
  177.             end    
  178.         else
  179.             DA_Total = 0
  180.             DA_Current = 0
  181.         end
  182.         if  (SPS_Current ~= nil ) then    --  Divine Aegis
  183.             if (SPS_Current >= SPS_Total) then
  184.                 SPS_Total = SPS_Current    
  185.             end    
  186.         else
  187.             SPS_Total = 0
  188.             SPS_Current = 0
  189.         end
  190.        
  191.        
  192.         CURRENT_AMOUNT2 = 0
  193.         ORGINAL_AMOUNT2 = 0
  194.         if PWS_Total ~= nil and PWS_Current ~= nil then
  195.             CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + PWS_Current
  196.             ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + PWS_Total
  197.         end
  198.         if DA_Total ~= nil and DA_Current ~= nil then
  199.             CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + DA_Current
  200.             ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + DA_Total
  201.         end
  202.         if SPS_Total ~= nil and SPS_Current ~= nil then
  203.             CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + SPS_Current
  204.             ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + SPS_Total
  205.         end
  206.    
  207.         AbsorbBar.UpdateBar()
  208.         return
  209.     end
  210.    
  211.     --Paladin
  212.     if AbsorbBarClass == "Paladin" and arg2 == "player"  then
  213.  
  214.  
  215.         _, _, _, _, _, _, _, _, _, _, _, _, _, _,SS_Current = UnitBuff("Player", AB_SS)
  216.  
  217.         if  (SS_Current ~= nil ) then    -- Sacred Shield
  218.             if (SS_Current >= SS_Total) then
  219.                 SS_Total = SS_Current
  220.             end
  221.         else
  222.             SS_Total = 0
  223.             SS_Current = 0
  224.         end
  225.  
  226.         CURRENT_AMOUNT2 = 0
  227.         ORGINAL_AMOUNT2 = 0
  228.         if SS_Total ~= nil and SS_Current ~= nil then
  229.             CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + SS_Current
  230.             ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + SS_Total
  231.         end
  232.  
  233.         AbsorbBar.UpdateBar()
  234.         return
  235.     end
  236.  
  237.     -- Warrior
  238.     if AbsorbBarClass == "Warrior" and arg2 == "player"  then
  239.    
  240.    
  241.         _, _, _, _, _, _, _, _, _, _, _, _, _, _,SB_Current = UnitBuff("Player", AB_SB)
  242.  
  243.         if  (SB_Current ~= nil ) then    -- Shield Barrier
  244.             if (SB_Current >= SB_Total) then
  245.                 SB_Total = SB_Current
  246.             end
  247.         else
  248.             SB_Total = 0
  249.             SB_Current = 0
  250.         end
  251.  
  252.         CURRENT_AMOUNT2 = 0
  253.         ORGINAL_AMOUNT2 = 0
  254.         if SB_Total ~= nil and SB_Current ~= nil then
  255.             CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + SB_Current
  256.             ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + SB_Total
  257.         end
  258.  
  259.         AbsorbBar.UpdateBar()
  260.         return
  261.     end
  262.  
  263. end
Attached Files
File Type: lua AbsorbBar.lua (13.6 KB, 56 views)
  Reply With Quote
01-14-19, 10:23 PM   #2
Kanegasi
A Firelord
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 487
Are you testing this in an external Lua environment? CreateFrame() only exists ingame and WoW is currently using Lua 5.1. Youíre better off testing addons ingame and using /reload whenever you make changes (as long as you didnít add or remove files).
  Reply With Quote
01-15-19, 02:34 AM   #3
d87
A Chromatic Dragonspawn
 
d87's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 152
In modern wow there's no need to scan buffs to calculate total absorb, you can just use UnitGetTotalAbsorbs("player")
So you're better off not using this addon, it can be easily replaced with a weakaura or something else probably
  Reply With Quote
01-15-19, 05:01 AM   #4
captainveet
A Defias Bandit
Join Date: Jan 2019
Posts: 3
Originally Posted by Kanegasi View Post
Are you testing this in an external Lua environment? CreateFrame() only exists ingame and WoW is currently using Lua 5.1. Youíre better off testing addons ingame and using /reload whenever you make changes (as long as you didnít add or remove files).

Yeah i was testing it out of the game, that's why this error seemed weird to me, thanks !
  Reply With Quote
01-15-19, 05:04 AM   #5
captainveet
A Defias Bandit
Join Date: Jan 2019
Posts: 3
Originally Posted by d87 View Post
In modern wow there's no need to scan buffs to calculate total absorb, you can just use UnitGetTotalAbsorbs("player")
So you're better off not using this addon, it can be easily replaced with a weakaura or something else probably
Oh ok that's interesting to know, i'll try to download weakaura again, i know i had problems with it in the past ( don't remember what the problem was though) but anyways, thanks for your reply
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Trying to add support for a shield to an old addon

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