Quantcast
WoWInterface - View Single Post - [ADDON_ACTION_BLOCKED] tried to call the protected function "<unnamed>:SetHeight()".
View Single Post
11-05-18, 06:20 AM   #3
Lyak
A Cyclonian
Join Date: Jul 2018
Posts: 46
Originally Posted by lightspark View Post
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!!!!!

Last edited by Lyak : 11-05-18 at 06:29 AM.
  Reply With Quote