WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   [ADDON_ACTION_BLOCKED] tried to call the protected function "<unnamed>:SetHeight()". (https://www.wowinterface.com/forums/showthread.php?t=56832)

Lyak 11-04-18 09:45 PM

[ADDON_ACTION_BLOCKED] tried to call the protected function "<unnamed>:SetHeight()".
 
Hi all,

I am currently making an addon that displays all the enemies' unitframe by reproducing nameplates based on NAME_PLATE_CREATED, NAME_PLATE_UNIT_ADDED, NAME_PLATE_UNIT_REMOVED events.

Lua Code:
  1. function AddOn:NAME_PLATE_CREATED(...)
  2.     local setting = AddOn.db.global;
  3.  
  4.     -- Create nameplate
  5.     local nameplate = CreateFrame("Frame", nil, self);
  6.     nameplate:SetSize(setting.width, setting.iconSize);
  7.    
  8.     -- Position each nameplates
  9.     local listLength = #self.nameplateList;
  10.     if (listLength == 0) then
  11.         nameplate:SetPoint("TOP");
  12.     else
  13.         nameplate:SetPoint("TOP", self.nameplateList[listLength], "BOTTOM", 0, -3);
  14.     end
  15.  
  16.     self.nameplateList[listLength + 1] = nameplate;
  17.    
  18.     local health = CreateFrame("StatusBar", nil, nameplate);
  19.     health:SetStatusBarTexture(LSM:Fetch("statusbar", setting.texture));
  20.     health:SetMinMaxValues(0, 1);
  21.     health:SetAllPoints(nameplate);
  22.    
  23.     nameplate.health = health;
  24.  
  25.     -- Adjust the height on nameplate creation
  26.     if (listLength == 1) then
  27.         self:SetHeight(setting.iconSize);
  28.     elseif (listLength > 1) then
  29.         self:SetHeight(self:GetHeight() + 3 + setting.iconSize);
  30.     end
  31. end
  32.  
  33. function InitializeHandler()
  34.     local setting = AddOn.db.global;
  35.  
  36.     local handler = CreateFrame("Frame", nil, UIParent, "SecureHandlerStateTemplate");
  37.     handler:SetWidth(setting.width);
  38.     handler:CustomSetPoint(setting.point);
  39.  
  40.     RegisterStateDriver(handler, "visibility", "[petbattle] hide; show");
  41.    
  42.     AddOn.handler = handler;
  43.  
  44.     handler.nameplateList = {};
  45. end

I am aware of that this taint is occurring because the new nameplates are being created and the height is set while in the combat.

+ The reason that I am using SecureHandlerStateTemplate is to hide such frame while in a pet battle (as it is shown in L#40).

Is there any possible solution to prevent such taint occurring? Or should I only use my handler only to hide/show the frame in/out of pet battle, and create another frame on top of it which manages visual part?

Thank you!

lightspark 11-04-18 11:56 PM

You really don't want to use secure templates for your nameplates, speaking from experience.

Moreover, aren't nameplates hidden while pet battling anyway? Why are you trying to do that manually? O_o

Lyak 11-05-18 06:20 AM

Quote:

Originally Posted by lightspark (Post 330761)
You really don't want to use secure templates for your nameplates, speaking from experience.

Moreover, aren't nameplates hidden while pet battling anyway? Why are you trying to do that manually? O_o

Hi lightspark,

First of all, it was a bad word choice of me :(

What I meant was that I am trying to create a list of unitframes which works like nameplates, but instead of hovering above the unit they will be lined up at a certain position.

Something like this:



I've made some modifications after posting this thread and now there are basically two templates being used.

Lua Code:
  1. function AddOn:ADDON_LOADED(...)
  2.     if (not ... == addonName) then
  3.         return;
  4.     end
  5.  
  6.     InitializeHandler();
  7.  
  8.     self:UnregisterEvent("ADDON_LOADED");
  9. end
  10.  
  11. -- @self - handler
  12. function AddOn:NAME_PLATE_CREATED(event, ...)
  13.     local setting = AddOn.db.global;
  14.  
  15.     -- Create nameplate
  16.     local nameplate = CreateFrame("Frame", nil, self, "SecureUnitButtonTemplate");
  17.     nameplate:SetSize(setting.width, setting.iconSize);
  18.    
  19.     local listLength = #self.nameplateList;
  20.     if (listLength == 0) then
  21.         nameplate:SetPoint("TOP");
  22.     else
  23.         nameplate:SetPoint("TOP", self.nameplateList[listLength], "BOTTOM", 0, -3);
  24.     end
  25.  
  26.     -- Assign unit for each nameplates so that they could mange the visibilities
  27.     nameplate:SetAttribute("unit", "nameplate" .. (listLength + 1));
  28.     RegisterUnitWatch(nameplate);
  29.  
  30.     self.nameplateList[listLength + 1] = nameplate;
  31.  
  32.     local health = CreateFrame("StatusBar", nil, nameplate);
  33.     health:SetStatusBarTexture(LSM:Fetch("statusbar", setting.texture));
  34.     health:SetMinMaxValues(0, 1);
  35.     health:SetAllPoints(nameplate);
  36.    
  37.     nameplate.health = health;
  38.  
  39.     -- Adjust the height of the nameplate on nameplate creation
  40.     if (listLength == 1) then
  41.         self:SetHeight(setting.iconSize);
  42.     elseif (listLength > 1) then
  43.         self:SetHeight(self:GetHeight() + 3 + setting.iconSize);
  44.     end
  45. end
  46.  
  47. function InitializeHandler()
  48.     local setting = AddOn.db.global;
  49.  
  50.     local handler = CreateFrame("Frame", nil, UIParent, "SecureHandlerStateTemplate");
  51.     handler:SetWidth(setting.width);
  52.     handler:CustomSetPoint(setting.point);
  53.  
  54.     RegisterStateDriver(handler, "visibility", "[petbattle] hide; show");
  55.    
  56.     AddOn.handler = handler;
  57.  
  58.     handler.nameplateList = {};
  59. end

One is SecureHandlerStateTemplate for handler object to hide/show frames when the player is in/out of the pet battle as I stated before and the other is SecureUnitButtonTemplate for each nameplates that are being created to give some functionalities like mouseover cast, etc.

The errors that I'm getting are:

Lua Code:
  1. [ADDON_ACTION_BLOCKED] AddOn '<AddOnName>' tried to call the protected function 'SecureStateDriverManager:SetAttribute()'.

Lua Code:
  1. Frame <FrameNameN>: Unknown script element OnClick

mmmmmmmmmmmmmmmmm................

Secure templates are so complicated!!!!!

Lyak 11-05-18 06:52 PM

Aight, just decided change the structure.

Instead of nameplates being created on NAME_PLATE_CREATED, I decided to create certain amount of nameplates on ADDON_LOADED which will no longer cry for

Lua Code:
  1. [ADDON_ACTION_BLOCKED] AddOn '<AddOnName>' tried to call the protected function 'SecureStateDriverManager:SetAttribute()'.

this error.

So, the current concern is

Lua Code:
  1. Frame <FrameName1>: Unknown script element OnClick
  2. Frame <FrameName2>: Unknown script element OnClick
  3. Frame <FrameName3>: Unknown script element OnClick
  4. Frame <FrameName4>: Unknown script element OnClick
  5. Frame <FrameName5>: Unknown script element OnClick
  6. Frame <FrameName6>: Unknown script element OnClick
  7. Frame <FrameName7>: Unknown script element OnClick
  8. Frame <FrameName8>: Unknown script element OnClick
  9. Frame <FrameName9>: Unknown script element OnClick
  10. Frame <FrameName10>: Unknown script element OnClick

Seriously... what are they?

I thought it was crying because it doesn't have an assigned OnClick script and so I actually gave an empty OnClick script

Lua Code:
  1. frame:SetScript("OnClick", function(self, button, down)
  2.            
  3. end);

then it starts to toss me the following.

Lua Code:
  1. frame doesn't have a "OnClick" script

I've been searching for the solution on google and the only result that I got was from those Z-perl (or X-perl) users reporting such issue and I couldn't really find the answer :confused:

Xrystal 11-05-18 08:54 PM

What frames have the name FrameName in it ? None of the code you have supplied includes frames with that naming.

The error message itself sounds like it is being caused by an xml file as no line numbers are being reported.

If you have other addons activated, try just your addon and see if those errors still occur.

Lyak 11-05-18 09:29 PM

Quote:

Originally Posted by Xrystal (Post 330772)
What frames have the name FrameName in it ? None of the code you have supplied includes frames with that naming.

Sorry I forgot to clearly state that.

They are the frames (nameplates) that I create on NAME_PLATE_CREATED event as shown in L#16 of my first reply.

Quote:

Originally Posted by Xrystal (Post 330772)
The error message itself sounds like it is being caused by an xml file as no line numbers are being reported.

If you have other addons activated, try just your addon and see if those errors still occur.

Interesting

The error persists only when the BugGrabber addon is on :confused:

What am I missing...?

I mean I am a big fan(?) of oUF and afaik oUF also uses SecureUnitButtonTemplate which it doesn't report such error even if the BugGrabber addon is turned on......

mmmmmmmmmmmmmmmmmmmmmmmm..................

Lyak 11-06-18 12:32 AM

Ah... I think I found why...

The object type for my nameplate frame was a Frame rather than a Button....

After changing the type to Button, it stopped crying for that OnClick issue.

Now the next step would be giving some functionalities like mouseover cast and etc ;)

lightspark 11-06-18 06:01 AM

So you're trying to make your own enemy grid, eh? Don't get your hopes up though, there's a reason why that addon is pretty much dead nowadays.

And yes, frames don't have onclick scripts, good that you figured it out yourself.

Lyak 11-06-18 02:14 PM

Quote:

Originally Posted by lightspark (Post 330778)
So you're trying to make your own enemy grid, eh? Don't get your hopes up though, there's a reason why that addon is pretty much dead nowadays.

And yes, frames don't have onclick scripts, good that you figured it out yourself.

Oh god................................. It already did exist................?

But why is it so?

Is that because of the same reason? Blizzard blocked some sort of functionality cause the idea was way too powerful?

lightspark 11-06-18 09:13 PM

Quote:

Originally Posted by Lyak (Post 330779)
Oh god................................. It already did exist................?

But why is it so?

Is that because of the same reason? Blizzard blocked some sort of functionality cause the idea was way too powerful?

Exactly, it's too OP. It allowed for very fluid DoT management across multiple targets, it's so fluid that it became trivial, and that's not something Blizz liked, so they gutted it.

Google "enemy grid nerf". It's a fun read :P

Lyak 11-07-18 04:31 AM

Quote:

Originally Posted by lightspark (Post 330785)
Exactly, it's too OP. It allowed for very fluid DoT management across multiple targets, it's so fluid that it became trivial, and that's not something Blizz liked, so they gutted it.

Google "enemy grid nerf". It's a fun read :P

Honestly, I agree with the point that this addon is OP, but at the same time, I would expect Blizzard to make it somewhat easier for those DoT based dealers to dealt with :(


All times are GMT -6. The time now is 11:54 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2019 MMOUI