WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Addon_action_blocked (https://www.wowinterface.com/forums/showthread.php?t=49196)

cokedrivers 04-13-14 08:50 AM

Addon_action_blocked
 
I keep getting this error when out on the Timeless Isle:
Code:

26x [ADDON_ACTION_BLOCKED] AddOn "BasicUI" tried to call the protected function "OverrideActionBarButton1:Show()".
!BugGrabber-r198-release\BugGrabber.lua:552: in function <!BugGrabber\BugGrabber.lua:552>
<in C code>
FrameXML\ActionButton.lua:268: in function <FrameXML\ActionButton.lua:253>
<in C code>
FrameXML\ActionButton.lua:523: in function "ActionButton_OnEvent"
FrameXML\ActionButton.lua:124: in function <FrameXML\ActionButton.lua:117>

Locals:
nil

The only OverrideActionBar code I have in my addon is to move the vehicle bar above my datapanel.

Treeston from MMO Champions help me figure out a way to move it maybe it isn't correct.

So here is the code im currently using...
Lua Code:
  1. local bottom = function() end
  2.            
  3.             -- Main Menu Bar
  4.             MainMenuBar:ClearAllPoints()
  5.             MainMenuBar:SetPoint("BOTTOM", DataPanel, "TOP", 0, -3)
  6.             MainMenuBar.ClearAllPoints = bottom
  7.             MainMenuBar.SetPoint = bottom
  8.            
  9.             -- Vehicle Bar
  10.             OverrideActionBar:ClearAllPoints()
  11.             OverrideActionBar:SetPoint("BOTTOM", DataPanel, "TOP", 0, -3)
  12.             OverrideActionBar.ClearAllPoints = bottom
  13.             OverrideActionBar.SetPoint = bottom
  14.            
  15.             -- Pet Battle Bar
  16.             PetBattleFrame.BottomFrame:ClearAllPoints()
  17.             PetBattleFrame.BottomFrame:SetPoint("BOTTOM", DataPanel, "TOP", 0, -3)
  18.             PetBattleFrame.BottomFrame.ClearAllPoints = bottom
  19.             PetBattleFrame.BottomFrame.SetPoint = bottom

I'm wondering if it might need to be a secure hook or maybe I could hide my datapanel when any vehicle UI shows up.

Maybe something like:
Lua Code:
  1. hooksecurefunc('OverrideActionBar_SetDefaultAnchor', function(self)
  2.                 self:SetPoint(("BOTTOM", DataPanel, "TOP", 0, -3)
  3.             end)

Still learning so any help would be great.

Thanks
Coke

Duugu 04-13-14 10:38 AM

Well, what did you expect? :) You're overiding functions of protected frames.

Secure hook or not ... if you try to move protected frames from unsecure code in combat this action would be blocked.

Why don't you move the frames once if the addon loads? Are they re-anchored on the fly during normal gameplay?

cokedrivers 04-13-14 03:16 PM

Quote:

Originally Posted by Duugu (Post 292059)
Well, what did you expect? :) You're overiding functions of protected frames.

Secure hook or not ... if you try to move protected frames from unsecure code in combat this action would be blocked.

Why don't you move the frames once if the addon loads? Are they re-anchored on the fly during normal gameplay?

Not 100% sure about them moving, but I believe its like the trade skill window and arena frames the OverrideActionBar aka Vehicle Frame only activates when in a vehicle.

But when im not ins a vehicle and just in combat that is when the error pops up, like you said its a protected frame, maybe ill just have to move the datapanel to always show on the top although I really like it at the bottom of the screen.

Phanx 04-13-14 07:29 PM

All of these lines will break the default UI and spam you with "action blocked" errors:

Code:

MainMenuBar.ClearAllPoints = bottom
MainMenuBar.SetPoint = bottom

OverrideActionBar.ClearAllPoints = bottom
OverrideActionBar.SetPoint = bottom

PetBattleFrame.BottomFrame.ClearAllPoints = bottom
PetBattleFrame.BottomFrame.SetPoint = bottom

You can't override methods on secure frames this way. Even your other idea:

Code:

hooksecurefunc('OverrideActionBar_SetDefaultAnchor', function(self)
        self:SetPoint(("BOTTOM", DataPanel, "TOP", 0, -3)
end)

... will throw errors because -- aside from having an extra parenthesis -- you can't move a secure frame in combat either. You are on the right track, however. You just need to add a combat check to your secure hook:

Code:

hooksecurefunc("OverrideActionBar_SetDefaultAnchor", function(self)
        if not InCombatLockdown() then
                self:SetPoint("BOTTOM", DataPanel, "TOP", 0, -3)
        end
end)

You may also want to add a "queue" so that any frames that were moved during combat (when you can't move them) can be moved after combat ends:

Code:

local queue = {}

local queueHandler = CreateFrame("Frame")
queueHandler:RegisterEvent("PLAYER_REGEN_ENABLED")
queueHandler:SetScript("OnEvent", function(self, event)
        for i = 1, #queue do
                local frame, pointA, anchor, pointB, x, y = unpack(queue[i])
                frame:SetPoint(pointA, anchor, pointB, x, y)
        end
end)

hooksecurefunc("OverrideActionBar_SetDefaultAnchor", function(self)
        if not InCombatLockdown() then
                self:SetPoint("BOTTOM", DataPanel, "TOP", 0, -3)
        else
                tinsert(queue, { self, "BOTTOM", DataPanel, "TOP", 0, -3 })
        end
end)

Your other option, as you said, would be to hide your data panel while in a vehicle:

Code:

DataPanel:RegisterUnitEvent("UNIT_ENTERING_VEHICLE", "player")
DataPanel:RegisterUnitEvent("UNIT_EXITED_VEHICLE", "player")

DataPanel:SetScript("OnEvent", function(self, event, ...)
        if event == "UNIT_ENTERING_VEHICLE" then
                self:Hide()
        elseif event == "UNIT_EXITED_VEHICLE" then
                self:Show()
        end
end)


cokedrivers 04-14-14 09:00 AM

Quote:

Originally Posted by Phanx (Post 292075)
All of these lines will break the default UI and spam you with "action blocked" errors:

Code:

MainMenuBar.ClearAllPoints = bottom
MainMenuBar.SetPoint = bottom

OverrideActionBar.ClearAllPoints = bottom
OverrideActionBar.SetPoint = bottom

PetBattleFrame.BottomFrame.ClearAllPoints = bottom
PetBattleFrame.BottomFrame.SetPoint = bottom

You can't override methods on secure frames this way. Even your other idea:

Code:

hooksecurefunc('OverrideActionBar_SetDefaultAnchor', function(self)
        self:SetPoint(("BOTTOM", DataPanel, "TOP", 0, -3)
end)

... will throw errors because -- aside from having an extra parenthesis -- you can't move a secure frame in combat either. You are on the right track, however. You just need to add a combat check to your secure hook:

Code:

hooksecurefunc("OverrideActionBar_SetDefaultAnchor", function(self)
        if not InCombatLockdown() then
                self:SetPoint("BOTTOM", DataPanel, "TOP", 0, -3)
        end
end)

You may also want to add a "queue" so that any frames that were moved during combat (when you can't move them) can be moved after combat ends:

Code:

local queue = {}

local queueHandler = CreateFrame("Frame")
queueHandler:RegisterEvent("PLAYER_REGEN_ENABLED")
queueHandler:SetScript("OnEvent", function(self, event)
        for i = 1, #queue do
                local frame, pointA, anchor, pointB, x, y = unpack(queue[i])
                frame:SetPoint(pointA, anchor, pointB, x, y)
        end
end)

hooksecurefunc("OverrideActionBar_SetDefaultAnchor", function(self)
        if not InCombatLockdown() then
                self:SetPoint("BOTTOM", DataPanel, "TOP", 0, -3)
        else
                tinsert(queue, { self, "BOTTOM", DataPanel, "TOP", 0, -3 })
        end
end)

Your other option, as you said, would be to hide your data panel while in a vehicle:

Code:

DataPanel:RegisterUnitEvent("UNIT_ENTERING_VEHICLE", "player")
DataPanel:RegisterUnitEvent("UNIT_EXITED_VEHICLE", "player")

DataPanel:SetScript("OnEvent", function(self, event, ...)
        if event == "UNIT_ENTERING_VEHICLE" then
                self:Hide()
        elseif event == "UNIT_EXITED_VEHICLE" then
                self:Show()
        end
end)


Again Thank You for the help,

Beings that Vehicles and Pet Battle both hide the mainbar I went with the hide option so I had to modify the code a little.

Code:

                        -- Hide Panels When in a Vehicle or Pet Battle
                        MainPanel:RegisterUnitEvent("UNIT_ENTERING_VEHICLE", "player")
                        MainPanel:RegisterUnitEvent("UNIT_EXITED_VEHICLE", "player")
                        MainPanel:RegisterUnitEvent("PET_BATTLE_OPENING_START")
                        MainPanel:RegisterUnitEvent("PET_BATTLE_CLOSE")

                        MainPanel:SetScript("OnEvent", function(self, event, ...)
                                if event == "UNIT_ENTERING_VEHICLE" or event == "PET_BATTLE_OPENING_START" then
                                        self:Hide()
                                elseif event == "UNIT_EXITED_VEHICLE" or event == "PET_BATTLE_CLOSE" then
                                        self:Show()
                                end
                        end)

It hides the panel in both vehicle and pet battles, although the tooltips still show for each stat when moused over. Would I have to goto the tooltip part of each stat and add a event=="" to those to stop them from showing?

I currently have "if not InCombatLockdown() then" to stop tooltips in combat. Is there a "if not InVehicle" or "if not InPetBattle"

Thanks again Phanx.

Coke

Phanx 04-14-14 08:07 PM

Quote:

Originally Posted by cokedrivers (Post 292088)
It hides the panel in both vehicle and pet battles, although the tooltips still show for each stat when moused over. Would I have to goto the tooltip part of each stat and add a event=="" to those to stop them from showing?

That would indicate that your stat frames are not properly parented to the main panel, since when you hide a frame, all of its children are also hidden. Make sure your stat frames are parented to the panel (or parented to something else that's parented to the panel, etc.) or post your code if you need help figuring it out.

cokedrivers 04-15-14 08:27 PM

1 Attachment(s)
Quote:

Originally Posted by Phanx (Post 292094)
That would indicate that your stat frames are not properly parented to the main panel, since when you hide a frame, all of its children are also hidden. Make sure your stat frames are parented to the panel (or parented to something else that's parented to the panel, etc.) or post your code if you need help figuring it out.

I have attached my datapanel.lua the code is way to long to post on here. Below are some things I tried with no success.


I've tried the following:

In the main code:
Code:

if MainPanel:IsVisable() then
  -- PP Code Here
else
  return
end

The above code shows no text.


In the Stat it self:
Code:

if (MainPanel:IsVisable() ~= false) then
  PP(db.datapanel.armor, Text)
else
  return
end

The above code shows no text also.

In the stat in the game tooltip part of the code:
Code:

if MainPanel:Show() == true then
  -- Tooltip Code
else
  return
end

The above code loads the stat but shows no tooltip



The reason for 1 main panel and 3 smaller panels on top of the main panel is when setting up the locations for the stat positions it is a little over whelming to try to set up 9 locations vs making 3 panels and then only having to so a left, center and right. Then setting up the width MainPanel:GetWidth()/3 makes them all be the correct size to fit all 3 in the panel.


Thanks for taking so much time in helping me. As you can see I thinking im heading in the right direction when trying to figure out and learn new things.


When I looked up IsVisable() the example it gave me was

Code:

visable = MyObject:IsVisable()

Example:
if(MyFrame:IsVisible()) then
  MyAddon_UpdateSomeText(MyFrame);
end

So by this example I thought that the PP is the object and it was what I needed to try to hide, apparently I was wrong... again.

Thanks

Coke

Phanx 04-15-14 10:48 PM

Yep, the problem is exactly what I suspected:

Code:

                local Stat = CreateFrame('Frame')
                Stat:EnableMouse(true)
                Stat:SetFrameStrata('BACKGROUND')
                Stat:SetFrameLevel(3)

                local Text  = MainPanel:CreateFontString(nil, 'OVERLAY')
                Text:SetFont(db.media.fontNormal, db.media.fontSize,'THINOUTLINE')
                PP(db.datapanel.armor, Text)

Note that your frame has no parent. This is bad for a multitude of reasons -- it won't be properly hidden when the user presses Alt-Z to hide the UI, it won't scale properly when the user changes their UI scale, and it won't inherit anything from the frame that is logically its parent.

You later set the parent of the fontstring, but not the parent of the frame, so while the fontstring gets hidden, the frame does not. You should be passing around (and reparenting, resizing, positioning, etc) the whole plugin frame, not just its fontstring.

------

Unrelated to your actual problem, but somewhat important:

(1) Having functions with names like "PP" is a really bad idea. Nobody who reads your code to try to help you with it will have any clue what "PP" means, and you yourself will probably forget what "PP" means if you don't look at your code for a few weeks, months, or years. Addons aren't macros. Space isn't limited. Use names that make sense. In this case, after wasting a bunch of time finding where this function is defined and reading through its contents, I'd suggest calling it "PlacePlugin".

(2) Also, it's currently a global, along with such gems as "PL", "PC", and "PR", all of which are horrible choices for global variables/names... they're horrible names in general, but they're even worse as globals because if anyone else's addon accidentally leaks its own horribly named "PC" global, for example, it will likely break both addons. And if Blizzard accidentally leaks a global "PC", you could break the entire UI. Even "MainPanel" is not a good choice for a global name. Use unique, descriptive names for globals if you must make them, but avoid making them unless you actually need to. "BasicUI_MainPanel" would be a better choice for the name of this frame, and the left/center/right frames don't need global names at all.

(3) Putting the entire contents of your file in your OnEnable function doesn't really accomplish anything other than making your code unnecessarily unreadable, either. It's okay to define things in the main chunk of your file.

And finally, I know we've addressed this in at least one of your other threads, but you can't override methods on secure frames. This (and the many other sections like it) will not work:

Code:

                        PlayerFrame.ClearAllPoints = top
                        PlayerFrame.SetPoint = top


Phanx 04-15-14 11:22 PM

Here's a partial rewrite of your file:
http://pastebin.com/qL6gijfy

May or may not work as-is, but should give you some ideas on how to clean up the many problems your code. See comments for what I didn't include.

cokedrivers 04-17-14 12:35 PM

Quote:

Originally Posted by Phanx (Post 292116)
Here's a partial rewrite of your file:
http://pastebin.com/qL6gijfy

May or may not work as-is, but should give you some ideas on how to clean up the many problems your code. See comments for what I didn't include.

I'm on my phone at work at the moment but last night I was able to get the code to work but was not able to see the text of the plugin.

When I get home this evening I will pastebin the code so you can see it.

Thank you for helping a 40 year old, video game playing, none high school graduating, forklift driver to figure out this lua programming.

I think I'm starting to see some reasoning for the changes and starting to figure out (tho it may be a little bit at a time) how and why the lua code for wow works. Just my luck 9 years of playing wow and just before they launch their final explanation I'm starting to understand how it works... seems like I might be a day late and 3 Billion dollars short. LOL

Again thanks for all your help.
Coke

cokedrivers 04-17-14 06:33 PM

1 Attachment(s)
Ok here is the code that works, but as you can see in the screen shot I cannot see the text on the bar.

Datapanel

Coke

myrroddin 04-17-14 06:42 PM

Just a side note: I hope there is an option to turn off the load spam. It is all well and good to see an AddOn greet you the first time, letting you know it is loaded and working, but I loathe AddOns that continue to spit that spam out with no option to turn it off.

And yes, I have a few of them like that, and it drives me crazy.

semlar 04-17-14 07:10 PM

Quote:

Originally Posted by myrroddin (Post 292143)
I hope there is an option to turn off the load spam.

In case there isn't.. !sh (antispam addon)

cokedrivers 04-17-14 08:04 PM

Quote:

Originally Posted by myrroddin (Post 292143)
Just a side note: I hope there is an option to turn off the load spam. It is all well and good to see an AddOn greet you the first time, letting you know it is loaded and working, but I loathe AddOns that continue to spit that spam out with no option to turn it off.

And yes, I have a few of them like that, and it drives me crazy.

Not sure what you mean by "continue to spit the chat out" but my "Welcome" chat only loads when you log in or do a ReloadUI. It does not spam with load screens.

Coke

Phanx 04-17-14 09:05 PM

Quote:

Originally Posted by cokedrivers (Post 292147)
Not sure what you mean by "continue to spit the chat out" but my "Welcome" chat only loads when you log in or do a ReloadUI.

Yeah, that's annoying. Imagine that every addon you have installed prints a "welcome" message when you log into the game or reload your UI. If you only use one addon, that might be fine, but I have 146 addons installed, excluding plugins. If all of them felt the need to inform me every time I logged in that I'd installed them, that would be 146 lines of spam in my chat frame. Hopefully you see the problem.

If you feel the need for a "welcome" message at all, you should only print it the first time a user logs in with your addon (eg. its saved variables are nil). After that, presumably your users are able to remember that they're using your addon, and able to see its frames on their screen; you don't need to tell them over and over that they're using your addon.

cokedrivers 04-17-14 09:31 PM

Quote:

Originally Posted by Phanx (Post 292150)
Yeah, that's annoying. Imagine that every addon you have installed prints a "welcome" message when you log into the game or reload your UI. If you only use one addon, that might be fine, but I have 146 addons installed, excluding plugins. If all of them felt the need to inform me every time I logged in that I'd installed them, that would be 146 lines of spam in my chat frame. Hopefully you see the problem.

If you feel the need for a "welcome" message at all, you should only print it the first time a user logs in with your addon (eg. its saved variables are nil). After that, presumably your users are able to remember that they're using your addon, and able to see its frames on their screen; you don't need to tell them over and over that they're using your addon.

Understandable, I'll remove the greeting message.

Coke

Ketho 04-17-14 10:00 PM

There still seems to be some leaking globals for BasicUI_Datapanel.lua (checking with FindGlobals). Just a heads up
Code:

function <D:\BasicUI_Datapanel.lua:166,193> (89 instructions, 356 bytes at 0000000000392030)
        [169]        SETGLOBAL        8 -2        ; screenHeight
        [174]        SETGLOBAL        8 -7        ; freeScreenHeight
        [175]        SETGLOBAL        8 -8        ; column
        [177]        SETGLOBAL        13 -13        ; frame
        [184]        SETGLOBAL        13 -8        ; column
        [185]        SETGLOBAL        13 -7        ; freeScreenHeight
        [191]        SETGLOBAL        13 -7        ; freeScreenHeight
function <D:\BasicUI_Datapanel.lua:346,379> (92 instructions, 368 bytes at 000000000039BBC0)
        [353]        SETGLOBAL        2 -7        ; PanelLeft
        [354]        SETGLOBAL        2 -8        ; PanelCenter
        [355]        SETGLOBAL        2 -9        ; PanelRight


cokedrivers 04-18-14 09:30 PM

Quote:

Originally Posted by Ketho (Post 292153)
There still seems to be some leaking globals for BasicUI_Datapanel.lua (checking with FindGlobals). Just a heads up
Code:

function <D:\BasicUI_Datapanel.lua:166,193> (89 instructions, 356 bytes at 0000000000392030)
        [169]        SETGLOBAL        8 -2        ; screenHeight
        [174]        SETGLOBAL        8 -7        ; freeScreenHeight
        [175]        SETGLOBAL        8 -8        ; column
        [177]        SETGLOBAL        13 -13        ; frame
        [184]        SETGLOBAL        13 -8        ; column
        [185]        SETGLOBAL        13 -7        ; freeScreenHeight
        [191]        SETGLOBAL        13 -7        ; freeScreenHeight
function <D:\BasicUI_Datapanel.lua:346,379> (92 instructions, 368 bytes at 000000000039BBC0)
        [353]        SETGLOBAL        2 -7        ; PanelLeft
        [354]        SETGLOBAL        2 -8        ; PanelCenter
        [355]        SETGLOBAL        2 -9        ; PanelRight


Will try to look into these, thanks for the heads up.

Well couldn't figure out how to get the text to show so I went this route. Not sure if its any better then the original but everything hides and with a reload im able to adjust the stat positions.

Coke

myrroddin 04-19-14 05:14 AM

Quote:

Originally Posted by cokedrivers (Post 292151)
Understandable, I'll remove the greeting message.

Coke

You don't need to remove the message entirely, unless you want to go that route. When the AddOn is loaded (login or reloadUI) check a new saved variable. Call it BasicUI.message_seen or something. Do not put a default value; leave that blank.

Then do an if/then during ADDON_LOADED (or OnInitialize for Ace3 AddOns). OnInit only fires once, and you would do the following check after you have set up or validated your saved variables.
Code:

if BasicUI.message_seen then
    break -- don't print the load message. break instead of return to exit the if/then but not the whole function
else
    BasicUI.message_seen = true
    -- print your welcome message
end


cokedrivers 04-20-14 02:21 PM

Phanx,

Finally got your code to work.

It was missing where to place the text.
so I used:
Code:

Module:PlacePlugin(db.datapanel.armor, plugin.text)
Now it shows and work.

Will have to now recreate all the other stat to make them work as well.

Thank You very much for your help.
Coke


All times are GMT -6. The time now is 01:53 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI