Quantcast
Use section of LUA when setting larg Nameplates - WoWInterface
Thread Tools Display Modes
01-17-22, 01:09 PM   #1
Mandraxon
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 18
Use section of LUA when setting larg Nameplates

Hey all.

I am using a LUA code i had made ages ago.
The thing is when i do m+ i use small nameplates with things setup in one way.
in PvP I use a different code and set the Use large nameplates in Interface - Names.

i think this is tied to NamePlateVerticalScale

so what i want is when i use the small nameplates
i wish to use this code.

Code:
-- Nameplate rezice

local Frame = CreateFrame("Frame")
Frame:RegisterEvent("PLAYER_LOGIN")

Frame:SetScript("OnEvent", function(...)
SetCVar("nameplateMaxDistance", 45)
SetCVar("nameplateMaxScale", 1.0)
SetCVar("nameplateMinScale", 0.9)
SetCVar("nameplateLargerScale", 1.1)
SetCVar("nameplateGlobalScale", 1.3)
SetCVar("nameplateSelectedScale", 1.15)
SetCVar("nameplateSelfTopInset",0.62)
SetCVar("nameplateSelfBottomInset",0.32)
SetCVar("nameplateOtherTopInset", 0.1)
SetCVar("nameplateLargeTopInset", 0.1)
SetCVar('UnitNameGuildTitle', 0)
SetCVar('UnitNamePlayerPVPTitle', 0)
SetCVar("nameplateOverlapV", 0.9)
SetCVar("nameplateOverlapH", 1.4)
SetCVar("NameplatePersonalShowAlways", 1)
SetCVar("nameplateSelfScale", 1.2)

end)


--  Move nametag
    hooksecurefunc("DefaultCompactNamePlateFrameAnchorInternal",function(frame)
        frame.name:ClearAllPoints();--  Clear nametag anchors
        PixelUtil.SetPoint(frame.name,"BOTTOM",frame.healthBar,"TOP",0,2);--    Set new anchor
    end);

--  Nametag font size
local function SetFont(obj,optSize)
    local fontName=obj:GetFont();
    obj:SetFont(fontName,optSize,"THINOUTLINE");
end
 
        SetFont(SystemFont_LargeNamePlate, 8)
        SetFont(SystemFont_NamePlate, 8)
        SetFont(SystemFont_LargeNamePlateFixed, 8)
        SetFont(SystemFont_NamePlateFixed, 8)

    -- move nameplates debuffs
hooksecurefunc(NameplateBuffContainerMixin,"UpdateAnchor",function(self)
    local parent=self:GetParent();
    local unit=parent.unit;
 
    if unit and ShouldShowName(parent) then
--      Replicate the calculation of the original function
        local offset=self:GetBaseYOffset()+((unit and UnitIsUnit(unit,"target")) and self:GetTargetYOffset() or 0);
        self:SetPoint("BOTTOM",parent,"TOP",0,-20);--    Apply offset here
    end--   We'll leave the false side of this alone to preserve the original anchor in that case
end);
 
-- nameplate buff size
hooksecurefunc(NameplateBuffContainerMixin,"OnLoad",function(self)
    self:SetScale(0.8);--   1 is default size.
end);

         
--  Disable nametag colors
 
DefaultCompactNamePlateFriendlyFrameOptions.colorNameBySelection = false
DefaultCompactNamePlateEnemyFrameOptions.colorNameBySelection = false
DefaultCompactNamePlatePlayerFrameOptions.colorNameBySelection = false

-- no Realmname on nameplates

hooksecurefunc("CompactUnitFrame_UpdateName", function(frame)
    if ShouldShowName(frame) then
        if frame.optionTable.colorNameBySelection then
            frame.name:SetText(GetUnitName(frame.unit))
        end
    end
end)
but if i tick the Large nameplates option i want to use this code

Code:
-- Nameplate rezice

local Frame = CreateFrame("Frame")
Frame:RegisterEvent("PLAYER_LOGIN")

Frame:SetScript("OnEvent", function(...)
SetCVar("nameplateMaxDistance", 45)
SetCVar("nameplateMaxScale", 1.0)
SetCVar("nameplateMinScale", 0.9)
SetCVar("nameplateLargerScale", 1.1)
SetCVar("nameplateGlobalScale", 0.9)
SetCVar("nameplateSelectedScale", 1.15)
SetCVar("nameplateSelfTopInset",0.62)
SetCVar("nameplateSelfBottomInset",0.32)
SetCVar("nameplateOtherTopInset", 0.1)
SetCVar("nameplateLargeTopInset", 0.1)
SetCVar('UnitNameGuildTitle', 0)
SetCVar('UnitNamePlayerPVPTitle', 0)
SetCVar("nameplateOverlapV", 0.9)
SetCVar("nameplateOverlapH", 1.4)
SetCVar("NameplatePersonalShowAlways", 1)
SetCVar("nameplateSelfScale", 1.2)

end)


--  Move nametag
    hooksecurefunc("DefaultCompactNamePlateFrameAnchorInternal",function(frame)
        frame.name:ClearAllPoints();--  Clear nametag anchors
        PixelUtil.SetPoint(frame.name,"BOTTOM",frame.healthBar,"TOP",0,2);--    Set new anchor
    end);

--  Nametag font size
local function SetFont(obj,optSize)
    local fontName=obj:GetFont();
    obj:SetFont(fontName,optSize,"THINOUTLINE");
end
 
        SetFont(SystemFont_LargeNamePlate, 8)
        SetFont(SystemFont_NamePlate, 8)
        SetFont(SystemFont_LargeNamePlateFixed, 8)
        SetFont(SystemFont_NamePlateFixed, 8)

    -- move nameplates debuffs
hooksecurefunc(NameplateBuffContainerMixin,"UpdateAnchor",function(self)
    local parent=self:GetParent();
    local unit=parent.unit;
 
    if unit and ShouldShowName(parent) then
--      Replicate the calculation of the original function
        local offset=self:GetBaseYOffset()+((unit and UnitIsUnit(unit,"target")) and self:GetTargetYOffset() or 0);
        self:SetPoint("BOTTOM",parent,"TOP",0,-11);--    Apply offset here
    end--   We'll leave the false side of this alone to preserve the original anchor in that case
end);
 
-- nameplate buff size
hooksecurefunc(NameplateBuffContainerMixin,"OnLoad",function(self)
    self:SetScale(1.2);--   1 is default size.
end);

         
--  Disable nametag colors
 
DefaultCompactNamePlateFriendlyFrameOptions.colorNameBySelection = false
DefaultCompactNamePlateEnemyFrameOptions.colorNameBySelection = false
DefaultCompactNamePlatePlayerFrameOptions.colorNameBySelection = false

-- no Realmname on nameplates

hooksecurefunc("CompactUnitFrame_UpdateName", function(frame)
    if ShouldShowName(frame) then
        if frame.optionTable.colorNameBySelection then
            frame.name:SetText(GetUnitName(frame.unit))
        end
    end
end)
how can i do this ?
/M
  Reply With Quote
02-13-22, 07:56 PM   #2
Zaqqari
A Deviate Faerie Dragon
Join Date: Aug 2019
Posts: 11
I'm curious about this as well. I have been using the script you posted here to move the nameplate auras, and I have issues in dungeon and raid instances. Friendly nameplates are not allowed to be modified in those instances, so I get too many addon errors when I do them.

Is there any way to modify the script to never touch friendly nameplates while in those protected instances? The first line is creating errors every time it tries to run.

Lua Code:
  1. hooksecurefunc(NameplateBuffContainerMixin,"UpdateAnchor",function(self)
  2.     local parent=self:GetParent();
  3.     local unit=parent.unit;
  4.  
  5.     if unit and not ShouldShowName(parent) and not UnitIsUnit(self.unit, "player") then
  6.         local offset=self:GetBaseYOffset()+((unit and UnitIsUnit(unit,"target")) and self:GetTargetYOffset() or 0);
  7.         self:SetPoint("BOTTOM",parent,"TOP",0,-18);
  8.     end
  9. end);
  Reply With Quote
02-13-22, 08:45 PM   #3
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,015
Originally Posted by Zaqqari View Post
Is there any way to modify the script to never touch friendly nameplates while in those protected instances? The first line is creating errors every time it tries to run.

Something like
Lua Code:
  1. hooksecurefunc(NameplateBuffContainerMixin, "UpdateAnchor", function(self)
  2.     if IsInInstance() then return end
  3.     -- do stuff
  4. end
  Reply With Quote
02-13-22, 11:48 PM   #4
Zaqqari
A Deviate Faerie Dragon
Join Date: Aug 2019
Posts: 11
That does work for completely disabling the script in all instances, but I want something more specific. I'm trying to only disable it on friendly nameplates and only when friendly nameplates are inaccessible by addons (dungeons and raids, I think).
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Use section of LUA when setting larg Nameplates

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