Text Tag HP #1400


  • Bad Fix
  • Enhancment
  • Enhancement
Closed
  • senxs created this issue Jan 17, 2020

    So, for quite some time now I've been look for a way to add decimal commas to large numbers, huge QoL improvement for me.

    With that in mind i looked online how to create a custom tag and come across this code :
    http://lua-users.org/wiki/FormattingNumbers

    function comma_value(n) -- credit http://richard.warburton.it
    	local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
    	return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
    end

    Have in mind that i know almost nothing of coding, tried my best to figure it out how to add that to a new text tag, asked in some discords and a friend came up with this

     

    function(unit)
        function comma_value(n) -- credit http://richard.warburton.it
            local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
            return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
        end
        if( UnitIsDead(unit) ) then
            return ShadowUFLocals["Dead"]
        -- Unit is dead, and they have released
        elseif( UnitIsGhost(unit) ) then
            return ShadowUFLocals["Ghost"]
        -- Unit is no longer online
        elseif( not UnitIsConnected(unit) ) then
            return ShadowUFLocals["Offline"]
        else
            return string.format("%s/%s", comma_value(UnitHealth(unit)), comma_value(UnitHealthMax(unit))) 
        end    
    end 

     Works fine till i relog, then i get this lua errors 

     

    1x [string "return function(unit, unitOwner)..."]:13: attempt to index global 'ShadowUFLocals' (a nil value)
    [string "return function(unit, unitOwner)
        function comma_value(n) -- credit http://richard.warburton.it
            local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
            return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
        end
        if( UnitIsDead(unit) ) then
            return ShadowUFLocals["Dead"]
        -- Unit is dead, and they have released
        elseif( UnitIsGhost(unit) ) then
            return ShadowUFLocals["Ghost"]
        -- Unit is no longer online
        elseif( not UnitIsConnected(unit) ) then
            return ShadowUFLocals["Offline"]
        else
            return string.format("%s/%s", comma_value(UnitHealth(unit)), comma_value(UnitHealthMax(unit))) 
        end    
    end "]:13: in function `func'
    [string "@ShadowedUnitFrames\modules\tags.lua"]:232: in function `UpdateTags'
    [string "@ShadowedUnitFrames\modules\layout.lua"]:444: in function `InitFontString'
    [string "@ShadowedUnitFrames\modules\layout.lua"]:466: in function `SetupText'
    [string "@ShadowedUnitFrames\modules\layout.lua"]:144: in function `Load'
    [string "@ShadowedUnitFrames\modules\units.lua"]:303: in function `SetVisibility'
    [string "@ShadowedUnitFrames\modules\units.lua"]:605: in function <ShadowedUnitFrames\modules\units.lua:435>
    [string "=[C]"]: in function `SetAttribute'
    [string "@ShadowedUnitFrames\modules\units.lua"]:956: in function `LoadUnit'
    [string "@ShadowedUnitFrames\modules\units.lua"]:1329: in function `InitializeFrame'
    [string "@ShadowedUnitFrames\ShadowedUnitFrames-v4.2.8.lua"]:263: in function `LoadUnits'
    [string "@ShadowedUnitFrames\ShadowedUnitFrames-v4.2.8.lua"]:86: in function `OnInitialize'
    [string "@ShadowedUnitFrames\ShadowedUnitFrames-v4.2.8.lua"]:907: in function <...aceShadowedUnitFrames\ShadowedUnitFrames.lua:905>
    
    Locals:
    unit = "target"
    unitOwner = "target"
    (*temporary) = nil
    (*temporary) = "target"
    (*temporary) = false
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = "attempt to index global 'ShadowUFLocals' (a nil value)"
    

     

    3x ShadowedUnitFrames\modules\auras-Auras.lua:658: attempt to index field 'buffs' (a nil value)
    [string "@ShadowedUnitFrames\modules\auras-Auras.lua"]:658: in function <ShadowedUnitFrames\modules\auras.lua:649>
    [string "@ShadowedUFFacade\ShadowedUFFacade-1.5.3.lua"]:67: in function <ShadowedUFFacade\ShadowedUFFacade.lua:65>
    [string "@ShadowedUF_NotMyAuras\ShadowedUF_NotMyAuras-v0.1.1.lua"]:125: in function `?'
    [string "@ShadowedUnitFrames\modules\units.lua"]:36: in function `FullUpdate'
    [string "@ShadowedUnitFrames\modules\units.lua"]:370: in function `CheckUnitStatus'
    [string "@ShadowedUnitFrames\modules\units.lua"]:226: in function <ShadowedUnitFrames\modules\units.lua:223>
    [string "=[C]"]: in function `Show'
    [string "@FrameXML\SecureStateDriver.lua"]:83: in function <FrameXML\SecureStateDriver.lua:73>
    [string "@FrameXML\SecureStateDriver.lua"]:137: in function <FrameXML\SecureStateDriver.lua:119>
    
    Locals:
    self = <table> {
     OnDisable = <function> defined @ShadowedUnitFrames\modules\auras.lua:17
     updateButton = <function> defined @ShadowedUnitFrames\modules\auras.lua:219
     UpdateFilter = <function> defined @ShadowedUnitFrames\modules\auras.lua:488
     scan = <function> defined @ShadowedUnitFrames\modules\auras.lua:588
     OnConfigurationLoad = <function> defined @ShadowedUF_NotMyAuras\ShadowedUF_NotMyAuras.lua:140
     OnEnable = <function> defined @ShadowedUnitFrames\modules\auras.lua:7
     OnLayoutApplied = <function> defined @ShadowedUnitFrames\modules\auras.lua:327
     moduleKey = "auras"
     moduleName = "Auras"
     Update = <function> defined @ShadowedUF_NotMyAuras\ShadowedUF_NotMyAuras.lua:119
     anchorGroupToGroup = <function> defined @ShadowedUnitFrames\modules\auras.lua:617
    }
    frame = SUFUnittarget {
     0 = <userdata>
     OnEnter = <function> defined @ShadowedUnitFrames\modules\units.lua:662
     UnregisterAll = <function> defined @ShadowedUnitFrames\modules\units.lua:140
     isDead = false
     auras = <table> {
     }
     registeredEvents = <table> {
     }
     UnitClassToken = <function> defined @ShadowedUnitFrames\modules\units.lua:677
     powerBar = <unnamed> {
     }
     RegisterNormalEvent = <function> defined @ShadowedUnitFrames\modules\units.lua:62
     SetVisibility = <function> defined @ShadowedUnitFrames\modules\units.lua:241
     topFrameLevel = 5
     RegisterUpdateFunc = <function> defined @ShadowedUnitFrames\modules\units.lua:113
     SetBlockColor = <function> defined @ShadowedUnitFrames\modules\units.lua:186
     unitType = "target"
     SetRangeAlpha = <function> defined @ShadowedUnitFrames\modules\units.lua:174
     visibility = <table> {
     }
     indicators = <unnamed> {
     }
     unitInitialized = true
     unitRealType = "target"
     unit = "target"
     ReregisterUnitEvents = <function> defined @ShadowedUnitFrames\modules\units.lua:41
     fontStrings = <table> {
     }
     unitGUID = "Player-3209-09025FB4"
     hasStateWatch = false
     RegisterUnitEvent = <function> defined @ShadowedUnitFrames\modules\units.lua:107
     comboPoints = <unnamed> {
     }
     altPowerBar = <unnamed> {
     }
     emptyBar = <unnamed> {
     }
     healAbsorb = <unnamed> {
     }
     unitEventOverrides = <table> {
     }
     auraIndicators = <unnamed> {
     }
     highFrame = <unnamed> {
     }
     UnregisterSingleEvent = <function> defined @ShadowedUnitFrames\modules\units.lua:90
     DisableRangeAlpha = <function> defined @ShadowedUnitFrames\modules\units.lua:166
     OnLeave = <function> defined @ShadowedUnitFrames\modules\units.lua:670
     fullUpdates = <table> {
     }
     UnregisterUpdateFunc = <function> defined @ShadowedUnitFrames\modules\units.lua:130
     isUnitVolatile = true
     BlizzRegisterUnitEvent = <function> defined =[C]:-1
     healthBar = <unnamed> {
     }
     FullUpdate = <function> defined @ShadowedUnitFrames\modules\units.lua:33
     SetBarColor = <function> defined @ShadowedUnitFrames\modules\units.lua:182
     unitOwner = "target"
    }
    config = <table> {
     height = 0.500000
     debuffs = <table> {
     }
     buffs = <table> {
     }
    }
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = "attempt to index field 'buffs' (a nil value)"
    scan = <function> defined @ShadowedUnitFrames\modules\auras.lua:588
    anchorGroupToGroup = <function> defined @ShadowedUnitFrames\modules\auras.lua:617
    

     Can you help me figure out how to fix this? or a better way to add the decimal comma?

     

  • senxs added the tags Bad Fix Enhancement Enhancment Jan 17, 2020
  • senxs edited description Jan 17, 2020
  • nevcairiel closed issue Jan 28, 2020
  • nevcairiel posted a comment Jan 28, 2020

    ShadowUFLocals is not a thing, replace it with ShadowUF.L,  eg. ShadowUF.L["Ghost"]


To post a comment, please login or register a new account.