theonlyshade |
03-18-23 06:58 PM |
"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!
|