Thread Tools Display Modes
03-18-23, 06:58 PM   #1
theonlyshade
A Defias Bandit
Join Date: Mar 2023
Posts: 2
"Addon has been blocked from an action only available to the Blizzard UI" Error

Hi all,

I want to preface my very little experience with WoW Addon creation. This is my a simple addon that makes the spell glow on my action bar. It takes in the spellID for the spell I want to track and the spellID for the condition required for it. I just started learning and got to the point where my addon is mostly working but I frequently am getting this error:



I noticed that when I initially load and use the Addon I am able to use it just fine but when I get into BGs/Arenas it will pop out when I press my key binds for my actionbar. The error persists even after I get out of BGs/Arenas. I also noticed that it works fine if I were to press the spells on my actionbar via mouse click.

Here's my TOC:
Code:
## Interface: 01332
## Title: Shade's CD
## Author: TheOnlyShade
## Version: 1.0
## SavedVariables: OffCooldownGlowingBorderDB
## SavedVariablesPerCharacter: OffCooldownGlowingBorderDB

main.lua
Here's my lua code:
Code:
-- Saved Variables table to store tracked spell and condition IDs
local defaultTrackedSpells = {}
OffCooldownGlowingBorderDB = OffCooldownGlowingBorderDB or defaultTrackedSpells

local function IsSpellOffCooldown(spellId)
    local start, duration = GetSpellCooldown(spellId)
    return start == 0 or (GetTime() - start) >= duration
end

local function HasBuffOrDebuff(spellId)
    local i = 1
    while true do
        local _, _, _, _, _, _, _, _, _, buffSpellId = UnitBuff("target", i)
        if not buffSpellId then break end
        if buffSpellId == spellId then
            return true
        end
        i = i + 1
    end

    i = 1
    while true do
        local _, _, _, _, _, _, _, _, _, debuffSpellId = UnitDebuff("target", i)
        if not debuffSpellId then break end
        if debuffSpellId == spellId then
            return true
        end
        i = i + 1
    end

    return false
end

local function UpdateActionButton(actionButton)
    local actionType, spellId = GetActionInfo(actionButton.action)
    if actionType == "spell" and spellId and OffCooldownGlowingBorderDB[spellId] then
        if IsSpellOffCooldown(spellId) and not HasBuffOrDebuff(OffCooldownGlowingBorderDB[spellId]) then
            ActionButton_ShowOverlayGlow(actionButton)
        else
            ActionButton_HideOverlayGlow(actionButton)
        end
    end
end

local function UpdateAllActionButtons()
    for i = 1, 12 do
        for j = 1, 6 do
            local actionButton = _G["MultiBarBottomLeftButton" .. i]
            UpdateActionButton(actionButton)
            actionButton = _G["MultiBarBottomRightButton" .. i]
            UpdateActionButton(actionButton)
            actionButton = _G["MultiBarLeftButton" .. i]
            UpdateActionButton(actionButton)
            actionButton = _G["MultiBarRightButton" .. i]
            UpdateActionButton(actionButton)
        end
    end
end

-- Function to update the tracked spells list and their conditions
local function UpdateTrackedSpells(inputText, conditionText)
    wipe(OffCooldownGlowingBorderDB)
    local spellIds = {}
    for spellId in string.gmatch(inputText, "%d+") do
        table.insert(spellIds, tonumber(spellId))
    end
    local conditionIds = {}
    for conditionId in string.gmatch(conditionText, "%d+") do
        table.insert(conditionIds, tonumber(conditionId))
    end
    for i, spellId in ipairs(spellIds) do
        OffCooldownGlowingBorderDB[spellId] = conditionIds[i]
    end
end

-- Create and set up configuration window
local configFrame = CreateFrame("Frame", "OffCooldownGlowingBorderConfigFrame", UIParent, "BasicFrameTemplate")
configFrame:SetSize(300, 150)
configFrame:SetPoint("CENTER")
configFrame:Hide()

configFrame.title = configFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
configFrame.title:SetPoint("TOP", 0, -10)
configFrame.title:SetText("Cooldown Glowing Border")

local inputBox = CreateFrame("EditBox", nil, configFrame, "InputBoxTemplate")
inputBox:SetPoint("TOP", 0, -40)
inputBox:SetSize(180, 30)
inputBox:SetAutoFocus(false)
inputBox:SetText("Enter spell IDs, separated by commas")

local conditionInputBox = CreateFrame("EditBox", nil, configFrame, "InputBoxTemplate")
conditionInputBox:SetPoint("TOP", 0, -80)
conditionInputBox:SetSize(180, 30)
conditionInputBox:SetAutoFocus(false)
conditionInputBox:SetText("Enter condition spell IDs, separated by commas")

conditionInputBox:SetScript("OnEditFocusLost", function(self)
    UpdateTrackedSpells(inputBox:GetText(), self:GetText())
end)

inputBox:SetScript("OnEditFocusLost", function(self)
    UpdateTrackedSpells(self:GetText())
end)

-- Slash command to show the configuration window
SLASH_OFFCOOLDOWNGLOWINGBORDER1 = "/ocgb"
SlashCmdList["OFFCOOLDOWNGLOWINGBORDER"] = function()
    configFrame:SetShown(not configFrame:IsShown())
end

local frame = CreateFrame("Frame", "OffCooldownGlowingBorderFrame", UIParent)
frame.elapsedTime = 0
frame:SetScript("OnUpdate", function(self, elapsed)
    self.elapsedTime = self.elapsedTime + elapsed
    if self.elapsedTime >= 0.1 then
        UpdateAllActionButtons()
        self.elapsedTime = 0
    end
end)

-- Add an event handler for the "PLAYER_LOGIN" event to load saved variables
frame:RegisterEvent("PLAYER_LOGIN")
frame:SetScript("OnEvent", function(self, event)
    if event == "PLAYER_LOGIN" then
        local trackedSpellsText = table.concat({unpack(OffCooldownGlowingBorderDB)}, ", ")
        inputBox:SetText(trackedSpellsText)
        local conditionSpellsText = table.concat({select(2, unpack(OffCooldownGlowingBorderDB))}, ", ")
        conditionInputBox:SetText(conditionSpellsText)
    end
end)
Here's a saved variable example:
Code:
OffCooldownGlowingBorderDB = {
	[980] = 980,
	[342938] = 342938,
	[172] = 146739,
}
I look forward to getting some help and learning why I am getting this error in WoW when using this addon.

Thanks in advance!

Last edited by theonlyshade : 03-18-23 at 07:00 PM.
  Reply With Quote
03-19-23, 06:52 AM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,359
Trivial things first

Your #interface: line has an invalid number (it won't break your addon but it'll make it show up as "out of date" on all clients)

11304 (classie/era)
30401 (wrath)
100005 (mainline) are valid numbers.

Secondly the snippet you posted won't help someone give you feedback.

The function looks ok (could use `AuraUtil` to do the buff / debuff scanning in a better way but that's not essential to your problem)

It is what you do with the actionbars after you get the information back from your function that we need to see.

Actionbuttons are secure and several actions are prohibited (move/show/hide/scale/re-anchor) outside the constraints of secureheaders and such.

TL;DR: Show your whole code / link to your addon or at least the parts that "touch" the actionbars/actionbutons.

Edit I can see the rest of the code now, not sure if edit or I missed it the first time.

Last edited by Dridzt : 03-19-23 at 07:00 AM.
  Reply With Quote
03-19-23, 12:24 PM   #3
theonlyshade
A Defias Bandit
Join Date: Mar 2023
Posts: 2
Originally Posted by Dridzt View Post
Trivial things first

Your #interface: line has an invalid number (it won't break your addon but it'll make it show up as "out of date" on all clients)

11304 (classie/era)
30401 (wrath)
100005 (mainline) are valid numbers.
Thank you so much, I didn't know what those numbers mean but it makes a lot more sense now.


Originally Posted by Dridzt View Post
The function looks ok (could use `AuraUtil` to do the buff / debuff scanning in a better way but that's not essential to your problem)
AuraUtil is definitely the better way to go for sure, I'll make that switch.


Originally Posted by Dridzt View Post
It is what you do with the actionbars after you get the information back from your function that we need to see.

Actionbuttons are secure and several actions are prohibited (move/show/hide/scale/re-anchor) outside the constraints of secureheaders and such.
I think this is the culprit but I couldn't pinpoint what. Is there a way to get more debug or logging on addon? I suspect that the glow effect is prohibited but I don't know how to confirm it.
  Reply With Quote
03-19-23, 02:34 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
I would try listening for the ADDON_ACTION_BLOCKED/ADDON_ACTION_FORBIDDEN events and printing the stack trace from debugstack(). It should give you an idea of the function responsible for raising a protected action error.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 03-19-23 at 02:38 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » "Addon has been blocked from an action only available to the Blizzard UI" Error

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