Originally Posted by lightspark
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:
function AddOn:ADDON_LOADED(...)
if (not ... == addonName) then
return;
end
InitializeHandler();
self:UnregisterEvent("ADDON_LOADED");
end
-- @self - handler
function AddOn:NAME_PLATE_CREATED(event, ...)
local setting = AddOn.db.global;
-- Create nameplate
local nameplate = CreateFrame("Frame", nil, self, "SecureUnitButtonTemplate");
nameplate:SetSize(setting.width, setting.iconSize);
local listLength = #self.nameplateList;
if (listLength == 0) then
nameplate:SetPoint("TOP");
else
nameplate:SetPoint("TOP", self.nameplateList[listLength], "BOTTOM", 0, -3);
end
-- Assign unit for each nameplates so that they could mange the visibilities
nameplate:SetAttribute("unit", "nameplate" .. (listLength + 1));
RegisterUnitWatch(nameplate);
self.nameplateList[listLength + 1] = nameplate;
local health = CreateFrame("StatusBar", nil, nameplate);
health:SetStatusBarTexture(LSM:Fetch("statusbar", setting.texture));
health:SetMinMaxValues(0, 1);
health:SetAllPoints(nameplate);
nameplate.health = health;
-- Adjust the height of the nameplate on nameplate creation
if (listLength == 1) then
self:SetHeight(setting.iconSize);
elseif (listLength > 1) then
self:SetHeight(self:GetHeight() + 3 + setting.iconSize);
end
end
function InitializeHandler()
local setting = AddOn.db.global;
local handler = CreateFrame("Frame", nil, UIParent, "SecureHandlerStateTemplate");
handler:SetWidth(setting.width);
handler:CustomSetPoint(setting.point);
RegisterStateDriver(handler, "visibility", "[petbattle] hide; show");
AddOn.handler = handler;
handler.nameplateList = {};
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:
[ADDON_ACTION_BLOCKED] AddOn '<AddOnName>' tried to call the protected function 'SecureStateDriverManager:SetAttribute()'.
Lua Code:
Frame <FrameNameN>: Unknown script element OnClick
mmmmmmmmmmmmmmmmm................
Secure templates are so complicated!!!!!