WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Use section of LUA when setting larg Nameplates (https://www.wowinterface.com/forums/showthread.php?t=59023)

Mandraxon 01-17-22 01:09 PM

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

Zaqqari 02-13-22 07:56 PM

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);

Ketho 02-13-22 08:45 PM

Quote:

Originally Posted by Zaqqari (Post 340321)
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

Zaqqari 02-13-22 11:48 PM

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).


All times are GMT -6. The time now is 10:07 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI