Thread Tools Display Modes
08-22-16, 11:58 AM   #1
plopek
A Deviate Faerie Dragon
AddOn Compiler - Click to view compilations
Join Date: Aug 2014
Posts: 18
Question ArenaFrames script - lua error

Hello,

So i have this script from some russian forum. I made it to work to my needs in legion, but I'm getting some error in some situation like killing mobs out of the world. I can't really specify when. It seems like its happens randomly. What I know it is trying to run outside of arena when it is not supposed to.

Lua Code:
  1. 12x [ADDON_ACTION_BLOCKED] AddOn 'Mods' tried to call the protected function 'ArenaEnemyFrames:ClearAllPoints()'.
  2. !BugGrabber\BugGrabber.lua:573: in function <!BugGrabber\BugGrabber.lua:573>
  3. [C]: in function `ClearAllPoints'
  4. FrameXML\UIParent.lua:2769: in function `UIParentManageFramePositions'
  5. FrameXML\UIParent.lua:2057: in function <FrameXML\UIParent.lua:2044>
  6. [C]: in function `SetAttribute'
  7. FrameXML\UIParent.lua:2807: in function `UIParent_ManageFramePositions'
  8. FrameXML\MainMenuBar.lua:384: in function `MainMenuBarVehicleLeaveButton_Update'
  9. FrameXML\MainMenuBar.lua:358: in function <FrameXML\MainMenuBar.lua:357>
  10.  
  11. Locals:

Lua Code:
  1. -----------------------------------------------------------------------
  2. -----------------------------------------------------------------------
  3. local ArenaFrames = 1 -------------------------------------------------
  4. -----------------------------------------------------------------------
  5. -----------------------------------------------------------------------
  6.  
  7. --[[------------------------
  8.     Arena frames / trinkets
  9. --------------------------]]
  10.  
  11. if (ArenaFrames == 1) then
  12.     local trinkets = {}
  13.     local events = CreateFrame("Frame")
  14.     function events:ADDON_LOADED(addonName)
  15.         if addonName ~= "Blizzard_ArenaUI" then
  16.             return
  17.         end
  18.             ArenaEnemyFrame1:ClearAllPoints()
  19.             ArenaEnemyFrame1:SetPoint("CENTER", TargetFrame, "CENTER", 117, 265)       
  20.             ArenaEnemyFrame1.SetPoint = function() end 
  21.             ArenaEnemyFrame2:ClearAllPoints()
  22.             ArenaEnemyFrame2:SetPoint("BOTTOMLEFT", ArenaEnemyFrame1, "BOTTOMLEFT", 0, -60)
  23.             ArenaEnemyFrame2.SetPoint = function() end
  24.             ArenaEnemyFrame3:ClearAllPoints()
  25.             ArenaEnemyFrame3:SetPoint("BOTTOMLEFT", ArenaEnemyFrame1, "BOTTOMLEFT", 0, -120)
  26.             ArenaEnemyFrame3.SetPoint = function() end
  27.             ArenaEnemyFrame4:ClearAllPoints()
  28.             ArenaEnemyFrame4:SetPoint("BOTTOMLEFT", ArenaEnemyFrame1, "BOTTOMLEFT", 0, -180)
  29.             ArenaEnemyFrame4.SetPoint = function() end
  30.             ArenaEnemyFrame5:ClearAllPoints()
  31.             ArenaEnemyFrame5:SetPoint("BOTTOMLEFT", ArenaEnemyFrame1, "BOTTOMLEFT", 0, -240)
  32.             ArenaEnemyFrame5.SetPoint = function() end 
  33.                 ArenaPrepFrame1:ClearAllPoints()
  34.                 ArenaPrepFrame1:SetPoint("CENTER", TargetFrame, "CENTER", 117, 265)
  35.                 ArenaPrepFrame1.SetPoint = function() end
  36.                 ArenaPrepFrame2:ClearAllPoints()
  37.                 ArenaPrepFrame2:SetPoint("TOPRIGHT", ArenaPrepFrame1, "TOPRIGHT", 0, -50)
  38.                 ArenaPrepFrame2.SetPoint = function() end
  39.                 ArenaPrepFrame3:ClearAllPoints()
  40.                 ArenaPrepFrame3:SetPoint("TOPRIGHT", ArenaPrepFrame1, "TOPRIGHT", 0, -100)
  41.                 ArenaPrepFrame3.SetPoint = function() end
  42.                 ArenaPrepFrame4:ClearAllPoints()
  43.                 ArenaPrepFrame4:SetPoint("TOPRIGHT", ArenaPrepFrame1, "TOPRIGHT", 0, -150)
  44.                 ArenaPrepFrame4.SetPoint = function() end
  45.                 ArenaPrepFrame5:ClearAllPoints()
  46.                 ArenaPrepFrame5:SetPoint("TOPRIGHT", ArenaPrepFrame1, "TOPRIGHT", 0, -200)
  47.                 ArenaPrepFrame5.SetPoint = function() end
  48.             ArenaPrepFrames:SetScale(1.20)            
  49.             ArenaEnemyFrames:SetScale(1.20)        
  50.         local arenaFrame, trinket
  51.         for i = 1, MAX_ARENA_ENEMIES do
  52.             arenaFrame = "ArenaEnemyFrame"..i
  53.             trinket = CreateFrame("Cooldown", arenaFrame.."Trinket", ArenaEnemyFrames)
  54.             trinket:SetPoint("TOPRIGHT", arenaFrame, 35, -6)
  55.             trinket:SetSize(24, 24)
  56.             trinket.icon = trinket:CreateTexture(nil, "BACKGROUND")
  57.             trinket.icon:SetAllPoints()
  58.             trinket.icon:SetTexture("Interface\\Icons\\inv_jewelry_trinketpvp_02")
  59.             trinket:Hide()
  60.             trinkets["arena"..i] = trinket
  61.         end
  62.         self:UnregisterEvent("ADDON_LOADED")
  63.     end
  64.     function events:UNIT_SPELLCAST_SUCCEEDED(unitID, spell, rank, lineID, spellID)
  65.         if not trinkets[unitID] then
  66.             return
  67.         end
  68.         if spellID == 59752 or spellID == 42292 or spellID == 195710 then
  69.             CooldownFrame_Set(trinkets[unitID], GetTime(), 180, 1)
  70.             SendChatMessage("Trinket used by: "..GetUnitName(unitID, true), "PARTY")    
  71.         end
  72.     end
  73.     function events:PLAYER_ENTERING_WORLD()
  74.         local _, instanceType = IsInInstance()
  75.         if instanceType == "arena" then
  76.             self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
  77.         elseif self:IsEventRegistered("UNIT_SPELLCAST_SUCCEEDED") then
  78.             self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
  79.             for _, trinket in pairs(trinkets) do
  80.                 trinket:SetCooldown(0, 0)
  81.                 trinket:Hide()
  82.             end
  83.         end
  84.     end
  85.     SLASH_TEST1 = "/arena"
  86.     SlashCmdList["TEST"] = function(msg, editBox)
  87.         if not IsAddOnLoaded("Blizzard_ArenaUI") then
  88.             LoadAddOn("Blizzard_ArenaUI")
  89.         end
  90.         ArenaEnemyFrames:Show()
  91.        
  92.         local focusFrame
  93.             if FocusFrame:Show() then
  94.                 FocusFrame.classPortrait:SetTexture("Interface\\TargetingFrame\\UI-Classes-Circles")
  95.                 FocusFrame.classPortrait:SetTexCoord(unpack(CLASS_ICON_TCOORDS["WARRIOR"]))
  96.                 FocusFrame.name:SetText("Badguy")
  97.                 FocusFrame:Show()
  98.             end
  99.         local arenaFrame
  100.         for i = 1, 4 do
  101.             arenaFrame = _G["ArenaEnemyFrame"..i]      
  102.             arenaFrame.classPortrait:SetTexture("Interface\\TargetingFrame\\UI-Classes-Circles")
  103.             arenaFrame.classPortrait:SetTexCoord(unpack(CLASS_ICON_TCOORDS["WARRIOR"]))
  104.             arenaFrame.name:SetText("Badguy")
  105.             arenaFrame:Show()              
  106.             CooldownFrame_Set(trinkets["arena"..i], GetTime(), 180, 1)     
  107.         end
  108.     end
  109.     events:SetScript("OnEvent", function(self, event, ...) return self[event](self, ...) end)
  110.     events:RegisterEvent("ADDON_LOADED")
  111.     events:RegisterEvent("PLAYER_ENTERING_WORLD")
  112.     events:RegisterEvent("PLAYER_ENTERING_WORLD")
  113. end


Can you guys help me to get this issue solved.
Thank you in advance.

Last edited by plopek : 08-22-16 at 12:24 PM.
  Reply With Quote
08-22-16, 10:22 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You can't do things like this:

Code:
ArenaEnemyFrame1.SetPoint = function() end
When you override a method (eg. SetPoint) on a secure frame (eg. ArenaEnemyFrame1) then any time the default UI calls that method, it calls your (insecure, because it's in an addon) function instead of the original (secure, because it's in Blizzard code) function, and that makes the entire code path count as insecure. If that's happening while you're in combat, you get an "action blocked" error because insecure code isn't allowed to move secure frames while in combat.

Based on a quick skim of the default UI code, it looks like the default UI doesn't even move the arena frames directly -- it only moves an intermediate parent frame, "ArenaEnemyFrames". You should be able to solve the problem by re-parenting the individual arena frames to the UIParent instead, eg.

Code:
ArenaEnemyFrame1:SetParent(UIParent)
Do that before you ClearAllPoints and SetPoint.

Also, you probably want to do the same thing with the arena prep frames, which are named ArenaPrepFrame1 through ArenaPrepFrame5, otherwise they will show up in the default location.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-23-16, 12:11 PM   #3
plopek
A Deviate Faerie Dragon
AddOn Compiler - Click to view compilations
Join Date: Aug 2014
Posts: 18
Thank you for reply Phanx,

I've tried the method u mentioned but it didn't work. ArenaPrepFrames moved to desired location without error but ArenaFrames didn't move at all and it pops error as soon as game started.

Lua Code:
  1. 4x [ADDON_ACTION_BLOCKED] AddOn 'Mods' tried to call the protected function 'ArenaEnemyFrames:ClearAllPoints()'.
  2. !BugGrabber\BugGrabber.lua:573: in function <!BugGrabber\BugGrabber.lua:573>
  3. [C]: in function `ClearAllPoints'
  4. FrameXML\UIParent.lua:2769: in function `UIParentManageFramePositions'
  5. FrameXML\UIParent.lua:2057: in function <FrameXML\UIParent.lua:2044>
  6. [C]: in function `SetAttribute'
  7. FrameXML\UIParent.lua:2807: in function `UIParent_ManageFramePositions'
  8. FrameXML\BuffFrame.lua:318: in function `BuffFrame_UpdateAllBuffAnchors'
  9. FrameXML\BuffFrame.lua:103: in function `BuffFrame_Update'
  10. FrameXML\BuffFrame.lua:48: in function <FrameXML\BuffFrame.lua:44>
  11.  
  12. Locals:



I hope I did it the way you suggested
Lua Code:
  1. -----------------------------------------------------------------------
  2. -----------------------------------------------------------------------
  3. local ArenaFrames = 1 -------------------------------------------
  4. -----------------------------------------------------------------------
  5. -----------------------------------------------------------------------
  6.  
  7. --[[------------------------
  8.     Arena frames / trinkets
  9. --------------------------]]
  10.  
  11. if (ArenaFrames == 1) then
  12.     local trinkets = {}
  13.     local events = CreateFrame("Frame")
  14.     function events:ADDON_LOADED(addonName)
  15.         if addonName ~= "Blizzard_ArenaUI" then
  16.             return
  17.         end
  18.             ArenaEnemyFrame1:SetParent(UIParent)
  19.             ArenaEnemyFrame1:ClearAllPoints()
  20.             ArenaEnemyFrame1:SetPoint("CENTER", TargetFrame, "CENTER", 117, 265)       
  21.             --ArenaEnemyFrame1.SetPoint = function() end
  22.             ArenaEnemyFrame2:SetParent(UIParent)
  23.             ArenaEnemyFrame2:ClearAllPoints()
  24.             ArenaEnemyFrame2:SetPoint("BOTTOMLEFT", ArenaEnemyFrame1, "BOTTOMLEFT", 0, -60)
  25.             --ArenaEnemyFrame2.SetPoint = function() end
  26.             ArenaEnemyFrame3:SetParent(UIParent)
  27.             ArenaEnemyFrame3:ClearAllPoints()
  28.             ArenaEnemyFrame3:SetPoint("BOTTOMLEFT", ArenaEnemyFrame1, "BOTTOMLEFT", 0, -120)
  29.             --ArenaEnemyFrame3.SetPoint = function() end
  30.             ArenaEnemyFrame4:SetParent(UIParent)
  31.             ArenaEnemyFrame4:ClearAllPoints()
  32.             ArenaEnemyFrame4:SetPoint("BOTTOMLEFT", ArenaEnemyFrame1, "BOTTOMLEFT", 0, -180)
  33.             --ArenaEnemyFrame4.SetPoint = function() end
  34.             ArenaEnemyFrame5:SetParent(UIParent)
  35.             ArenaEnemyFrame5:ClearAllPoints()
  36.             ArenaEnemyFrame5:SetPoint("BOTTOMLEFT", ArenaEnemyFrame1, "BOTTOMLEFT", 0, -240)
  37.             --ArenaEnemyFrame5.SetPoint = function() end
  38.                 ArenaPrepFrame1:SetParent(UIParent)
  39.                 ArenaPrepFrame1:ClearAllPoints()
  40.                 ArenaPrepFrame1:SetPoint("CENTER", TargetFrame, "CENTER", 117, 265)
  41.                 --ArenaPrepFrame1.SetPoint = function() end
  42.                 ArenaPrepFrame2:SetParent(UIParent)
  43.                 ArenaPrepFrame2:ClearAllPoints()
  44.                 ArenaPrepFrame2:SetPoint("TOPRIGHT", ArenaPrepFrame1, "TOPRIGHT", 0, -50)
  45.                 --ArenaPrepFrame2.SetPoint = function() end
  46.                 ArenaPrepFrame3:SetParent(UIParent)
  47.                 ArenaPrepFrame3:ClearAllPoints()
  48.                 ArenaPrepFrame3:SetPoint("TOPRIGHT", ArenaPrepFrame1, "TOPRIGHT", 0, -100)
  49.                 --ArenaPrepFrame3.SetPoint = function() end
  50.                 ArenaPrepFrame4:SetParent(UIParent)
  51.                 ArenaPrepFrame4:ClearAllPoints()
  52.                 ArenaPrepFrame4:SetPoint("TOPRIGHT", ArenaPrepFrame1, "TOPRIGHT", 0, -150)
  53.                 --ArenaPrepFrame4.SetPoint = function() end
  54.                 ArenaPrepFrame5:SetParent(UIParent)
  55.                 ArenaPrepFrame5:ClearAllPoints()
  56.                 ArenaPrepFrame5:SetPoint("TOPRIGHT", ArenaPrepFrame1, "TOPRIGHT", 0, -200)
  57.                 --ArenaPrepFrame5.SetPoint = function() end
  58.             ArenaPrepFrames:SetScale(1.20)            
  59.             ArenaEnemyFrames:SetScale(1.20)        
  60.         local arenaFrame, trinket
  61.         for i = 1, MAX_ARENA_ENEMIES do
  62.             arenaFrame = "ArenaEnemyFrame"..i
  63.             trinket = CreateFrame("Cooldown", arenaFrame.."Trinket", ArenaEnemyFrames)
  64.             trinket:SetPoint("TOPRIGHT", arenaFrame, 35, -6)
  65.             trinket:SetSize(24, 24)
  66.             trinket.icon = trinket:CreateTexture(nil, "BACKGROUND")
  67.             trinket.icon:SetAllPoints()
  68.             trinket.icon:SetTexture("Interface\\Icons\\inv_jewelry_trinketpvp_02")
  69.             trinket:Hide()
  70.             trinkets["arena"..i] = trinket
  71.         end
  72.         self:UnregisterEvent("ADDON_LOADED")
  73.     end
  74.     function events:UNIT_SPELLCAST_SUCCEEDED(unitID, spell, rank, lineID, spellID)
  75.         if not trinkets[unitID] then
  76.             return
  77.         end
  78.         if spellID == 59752 or spellID == 42292 or spellID == 195710 then
  79.             CooldownFrame_Set(trinkets[unitID], GetTime(), 180, 1)
  80.             SendChatMessage("Trinket used by: "..GetUnitName(unitID, true), "PARTY")    
  81.         end
  82.     end
  83.     function events:PLAYER_ENTERING_WORLD()
  84.         local _, instanceType = IsInInstance()
  85.         if instanceType == "arena" then
  86.             self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
  87.         elseif self:IsEventRegistered("UNIT_SPELLCAST_SUCCEEDED") then
  88.             self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
  89.             for _, trinket in pairs(trinkets) do
  90.                 trinket:SetCooldown(0, 0)
  91.                 trinket:Hide()
  92.             end
  93.         end
  94.     end
  95.     SLASH_TEST1 = "/arena"
  96.     SlashCmdList["TEST"] = function(msg, editBox)
  97.         if not IsAddOnLoaded("Blizzard_ArenaUI") then
  98.             LoadAddOn("Blizzard_ArenaUI")
  99.         end
  100.         ArenaEnemyFrames:Show()
  101.         local focusFrame
  102.             if FocusFrame:Show() then
  103.                 FocusFrame.classPortrait:SetTexture("Interface\\TargetingFrame\\UI-Classes-Circles")
  104.                 FocusFrame.classPortrait:SetTexCoord(unpack(CLASS_ICON_TCOORDS["WARRIOR"]))
  105.                 FocusFrame.name:SetText("Badguy")
  106.                 FocusFrame:Show()
  107.             end
  108.         local arenaFrame
  109.         for i = 1, 4 do
  110.             arenaFrame = _G["ArenaEnemyFrame"..i]      
  111.             arenaFrame.classPortrait:SetTexture("Interface\\TargetingFrame\\UI-Classes-Circles")
  112.             arenaFrame.classPortrait:SetTexCoord(unpack(CLASS_ICON_TCOORDS["WARRIOR"]))
  113.             arenaFrame.name:SetText("Badguy")
  114.             arenaFrame:Show()              
  115.             CooldownFrame_Set(trinkets["arena"..i], GetTime(), 180, 1)     
  116.         end
  117.     end
  118.     events:SetScript("OnEvent", function(self, event, ...) return self[event](self, ...) end)
  119.     events:RegisterEvent("ADDON_LOADED")
  120.     events:RegisterEvent("PLAYER_ENTERING_WORLD")
  121.     events:RegisterEvent("PLAYER_ENTERING_WORLD")
  122. end
  Reply With Quote
08-24-16, 09:28 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I don't immediately see anything in your code that should cause that error. The only things I can think of are:

a) You forgot to reload the UI after saving your changes, or you forgot to save the file before reloading the UI.

b) You have some other code in the same addon that's doing Bad Things.

c) You are somehow already in combat when the Blizzard_ArenaUI loads -- but that should cause a different "action blocked" error whose stack trace doesn't originate within the Blizzard "move all the things" function.

Without any further information (b) seems like the most likely problem.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » ArenaFrames script pops error when combat start


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