Alternative to attach to Personal Player Resources - WoWInterface
Thread Tools Display Modes
07-05-19, 01:55 PM   #1
A Flamescale Wyrmkin
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 103
Alternative to attach to Personal Player Resources


Im attaching stuff to the personal player resources so that it moves with the camera.
In most cases the following code works perfectly:

Lua Code:
  1. function LybrialAnchors:SetupFrames()
  2.     if (self.anchorFrame) then
  3.         return;
  4.     end
  6.     self.anchorFrame = CreateFrame("Frame", "LybrialUIAnchor", UIParent);
  7.     self.anchorFrame:Hide();
  8.     self.anchorFrame:RegisterEvent("NAME_PLATE_UNIT_ADDED");
  9.     self.anchorFrame:RegisterEvent("NAME_PLATE_UNIT_REMOVED");         
  10.     self.anchorFrame.Attach = function(self, frame, frameTopLeft, frameBottomRight)
  11.         self:SetParent(frame);
  12.         self:ClearAllPoints();
  13.         self:SetPoint("TOPLEFT", frameTopLeft, "TOPLEFT", 0, 0);
  14.         self:SetPoint("BOTTOMRIGHT", frameBottomRight, "BOTTOMRIGHT", 0, 0);
  15.         self:Show();
  16.     end
  17.     self.anchorFrame.Detach = function(self, frame)
  18.         self:ClearAllPoints();
  19.         self:Hide();
  20.     end
  21.     self.anchorFrame.eventHandler = function(self, event, nameplate)
  22.         if (event == "NAME_PLATE_UNIT_ADDED") then
  23.             if (UnitIsUnit(nameplate, "player")) then
  24.                 local frame = C_NamePlate.GetNamePlateForUnit("player");
  26.                 if (frame) then
  27.                     LybrialAnchors.anchorFrame:Attach(frame, frame.UnitFrame.healthBar, NamePlateDriverFrame.classNamePlatePowerBar);
  28.                     LybrialAnchors.anchorFrame:Show();
  29.                     LybrialAnchors:OnUpdate();
  30.                 else
  31.                     LybrialAnchors.anchorFrame:Detach();
  32.                     LybrialAnchors.anchorFrame:Hide();
  33.                     LybrialAnchors:OnUpdate();
  34.                 end
  35.             end
  36.         elseif (event == "NAME_PLATE_UNIT_REMOVED") then
  37.             if (UnitIsUnit(nameplate, "player")) then
  38.                 LybrialAnchors.anchorFrame:Detach();
  39.                 LybrialAnchors.anchorFrame:Hide();
  40.                 LybrialAnchors:OnUpdate();
  41.             end
  42.         end
  43.     end
  44.     self.anchorFrame:SetScript("OnEvent", self.anchorFrame.eventHandler);
  45. end

Where it does not work Is for example when im in fight, accidently press alt + y (alt + z in USA)
which hides the UI, press it again to get the UI back while still being in fight. The UI is completely
messed up then and I can only fix it by getting out of the fight and reloading the UI (or doing alt +y
twice again).

Also when im attaching other addons, like grid2 for example, they sometimes call stuff like
which is now forbidden on nameplates.

So im thinking if there are alternatives. Can you for example attach stuff to the camera?
Or measure the diff between display border and characters Y position on the screen?
Any other alternative someone could think of?

Last edited by Lybrial : 07-05-19 at 02:00 PM.
  Reply With Quote
07-05-19, 07:59 PM   #2
A Molten Giant
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 505
My suggestion would be to change the keybind that hides the UI, like ctrl-alt-shift-P or something crazy enough that you'll never accidentally hit it and it doesn't interfere with any other keybind.
  Reply With Quote
07-06-19, 12:01 AM   #3
A Flamescale Wyrmkin
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 103
Yeah that was what I did actually
But there is other stuff happening. Attaching other AddOns to the player resources also
sometimes causes issues. For example on Grid2, everytime when you invite somone
Grid2 is getting measured and you will get errors when you attached Grid2 to the
personal player resources frame. Raven is not useable at all when you attach it.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Alternative to attach to Personal Player Resources

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off