1. #1

    Question [Classic] Default Nameplate Status Text Addon

    Hello, I use this script on retail to display percentage health in the middle of the default nameplates. Is there a simple way to modify this to do the same on classic WoW?

    Code:
    hooksecurefunc("CompactUnitFrame_UpdateHealth", function(frame)
    
    if not frame:IsForbidden() then
    local healthPercentage = ceil((UnitHealth(frame.displayedUnit) / UnitHealthMax(frame.displayedUnit) * 100)) -- Calculating a percentage value for health.
    if string.find(frame:GetName(), "CompactRaidFrame") then return end
    
    if not frame.health then
    frame.health = CreateFrame("Frame", nil, frame) -- Setting up health display frames.
    frame.health:SetSize(170,16)
    frame.health.text = frame.health.text or frame.health:CreateFontString(nil, "OVERLAY")
    frame.health.text:SetAllPoints(true)
    frame.health:SetFrameStrata("HIGH")
    frame.health:SetPoint("CENTER", frame.healthBar)
    frame.health.text:SetVertexColor(1, 1, 1)
    end
    
    if InterfaceOptionsNamesPanelUnitNameplatesMakeLarger:GetValue() == "1" then -- If 'Larger Nameplates' option is enabled.
    frame.health.text:SetFont("FONTS\\FRIZQT__.TTF", 8, "OUTLINE")
    else
    frame.health.text:SetFont("FONTS\\FRIZQT__.TTF", 6, "OUTLINE")
    end
    
    frame.health.text:SetText(healthPercentage .. "%") -- Update health numbers + percentages (player.)
    frame.health.text:Show() -- Thanks Blizzard...
    
    end
    end)

  2. #2
    still looking

  3. #3
    bumping again

  4. #4
    What errors do you get when trying to use it in Classic?

  5. #5
    This down below:
    Message: Interface\AddOns\Nameplate Test Addon\core.lua:17: attempt to index global 'InterfaceOptionsNamesPanelUnitNameplatesMakeLarger' (a nil value)
    Time: Mon Dec 9 02:01:11 2019
    Count: 2
    Stack: Interface\AddOns\Nameplate Test Addon\core.lua:17: attempt to index global 'InterfaceOptionsNamesPanelUnitNameplatesMakeLarger' (a nil value)
    Interface\AddOns\Nameplate Test Addon\core.lua:17: in function <Interface\AddOns\Nameplate Test Addon\core.lua:1>
    [C]: in function `CompactUnitFrame_UpdateHealth'
    Interface\FrameXML\CompactUnitFrame.lua:289: in function `CompactUnitFrame_UpdateAll'
    Interface\FrameXML\CompactUnitFrame.lua:176: in function `CompactUnitFrame_SetUnit'
    ...e\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:250: in function `OnAdded'
    ...e\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:84: in function `OnNamePlateAdded'
    ...e\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:42: in function <...e\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:33>

    Locals: frame = NamePlate1UnitFrame {
    0 = <userdata>
    selectionHighlight = <unnamed> {
    }
    maxDebuffs = 0
    unit = "nameplate1"
    RaidTargetFrame = <unnamed> {
    }
    maxDispelDebuffs = 0
    disableMouse = true
    inVehicle = false
    statusText = <unnamed> {
    }
    optionTable = <table> {
    }
    health = <unnamed> {
    }
    newUnit = true
    healthBar = <unnamed> {
    }
    name = <unnamed> {
    }
    maxBuffs = 0
    unitExists = true
    displayedUnit = "nameplate1"
    LevelFrame = <unnamed> {
    }
    }
    healthPercentage = 100
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = "CompactRaidFrame"
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = "attempt to index global 'InterfaceOptionsNamesPanelUnitNameplatesMakeLarger' (a nil value)"
    - - - Updated - - -

    Message: Interface\AddOns\Nameplate Test Addon\core.lua:17: attempt to index global 'InterfaceOptionsNamesPanelUnitNameplatesMakeLarger' (a nil value)
    Time: Mon Dec 9 02:02:35 2019
    Count: 12
    Stack: Interface\AddOns\Nameplate Test Addon\core.lua:17: attempt to index global 'InterfaceOptionsNamesPanelUnitNameplatesMakeLarger' (a nil value)
    Interface\AddOns\Nameplate Test Addon\core.lua:17: in function <Interface\AddOns\Nameplate Test Addon\core.lua:1>
    [C]: ?
    [C]: in function `CompactUnitFrame_UpdateHealth'
    Interface\FrameXML\CompactUnitFrame.lua:81: in function <Interface\FrameXML\CompactUnitFrame.lua:51>

    Locals: frame = NamePlate1UnitFrame {
    0 = <userdata>
    selectionHighlight = <unnamed> {
    }
    maxDebuffs = 0
    unit = "nameplate1"
    RaidTargetFrame = <unnamed> {
    }
    maxDispelDebuffs = 0
    disableMouse = true
    inVehicle = false
    statusText = <unnamed> {
    }
    optionTable = <table> {
    }
    health = <unnamed> {
    }
    newUnit = true
    healthBar = <unnamed> {
    }
    name = <unnamed> {
    }
    maxBuffs = 0
    unitExists = true
    displayedUnit = "nameplate1"
    LevelFrame = <unnamed> {
    }
    }
    healthPercentage = 0
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = "CompactRaidFrame"
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = "attempt to index global 'InterfaceOptionsNamesPanelUnitNameplatesMakeLarger' (a nil value)"
    Message: Interface\AddOns\Nameplate Test Addon\core.lua:17: attempt to index global 'InterfaceOptionsNamesPanelUnitNameplatesMakeLarger' (a nil value)
    Time: Mon Dec 9 02:02:26 2019
    Count: 1
    Stack: Interface\AddOns\Nameplate Test Addon\core.lua:17: attempt to index global 'InterfaceOptionsNamesPanelUnitNameplatesMakeLarger' (a nil value)
    Interface\AddOns\Nameplate Test Addon\core.lua:17: in function <Interface\AddOns\Nameplate Test Addon\core.lua:1>
    [C]: ?
    [C]: in function `CompactUnitFrame_UpdateHealth'
    Interface\FrameXML\CompactUnitFrame.lua:79: in function <Interface\FrameXML\CompactUnitFrame.lua:51>

    Locals: frame = NamePlate1UnitFrame {
    0 = <userdata>
    selectionHighlight = <unnamed> {
    }
    maxDebuffs = 0
    unit = "nameplate1"
    RaidTargetFrame = <unnamed> {
    }
    maxDispelDebuffs = 0
    disableMouse = true
    inVehicle = false
    statusText = <unnamed> {
    }
    optionTable = <table> {
    }
    health = <unnamed> {
    }
    newUnit = true
    healthBar = <unnamed> {
    }
    name = <unnamed> {
    }
    maxBuffs = 0
    unitExists = true
    displayedUnit = "nameplate1"
    LevelFrame = <unnamed> {
    }
    }
    healthPercentage = 88
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = "CompactRaidFrame"
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = "attempt to index global 'InterfaceOptionsNamesPanelUnitNameplatesMakeLarger' (a nil value)"

  6. #6
    That checkbox object for larger nameplates does not exist in classic. Take that part out and choose one of the SetFont lines to keep.


    addons
    weakauras
    Lua Wall of Shame
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

  7. #7
    I can't get it to work, I don't have much experience with lua so when I take the lines out you specified I assume I'm doing something wrong with formatting. Could you or someone else take it out and reply with the proper syntax?

  8. #8
    What you have (delete this whole section):

    Code:
    if InterfaceOptionsNamesPanelUnitNameplatesMakeLarger:GetValue() == "1" then -- If 'Larger Nameplates' option is enabled.
    frame.health.text:SetFont("FONTS\\FRIZQT__.TTF", 8, "OUTLINE")
    else
    frame.health.text:SetFont("FONTS\\FRIZQT__.TTF", 6, "OUTLINE")
    end

    What it should be (choose one):

    Code:
    frame.health.text:SetFont("FONTS\\FRIZQT__.TTF", 8, "OUTLINE")
    Code:
    frame.health.text:SetFont("FONTS\\FRIZQT__.TTF", 6, "OUTLINE")
    Last edited by Kanegasi; 2019-12-09 at 12:35 PM.


    addons
    weakauras
    Lua Wall of Shame
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

  9. #9
    Thank you very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •