#WrapTextInColorCode(text, color)

19 messages · Page 1 of 1 (latest)

frosty cypress
#

I'm trying to color %c by using the following code but it doesn't return anything. What's wrong?

function ()
    local value, color
    value = aura_env.manacost
    
    if aura_env.config["inverted"] then
        if value > 80000 then
            color = "FFFF0000"  -- Red
        elseif value > 60000 then
            color = "FFFFA500"  -- Orange
        elseif value > 40000 then
            color = "FFFFFF00"  -- Yellow
        elseif value > 20000 then
            color = "FF00FF00"  -- Green
        else
            color = "FF00FFFF"  -- Cyan
        end
    else
        if value < 20000 then
            color = "FFFF0000"  -- Red
        elseif value < 40000 then
            color = "FFFFA500"  -- Orange
        elseif value < 60000 then
            color = "FFFFFF00"  -- Yellow
        elseif value < 80000 then
            color = "FF00FF00"  -- Green
        else
            color = "FF00FFFF"  -- Cyan
        end
    end
    
    return WrapTextInColorCode(value,color)
end
compact hollow
#

!bugsack

paper owlBOT
frosty cypress
#

I get no errors there. The value isn't showing when return WrapTextInColorCode() is being used.
If I replace color = "FFFF0000" with return value, the corresponding value shows in white.

#

So, I just found the cause but now I need a way to make it work.

#

When I use "Big Numbers", it doesn't work. When I use "None", it works.

#

I guess my only option is to abbreviate the values by myself in the code, right?

#

Solved! I did it in the code.

compact hollow
#

You're not returning a number, you're returning a string so yeah, can't expect WA to handle that.
What you arguably should be doing is having the value be part of a trigger and using Conditions for all this. At which point the text is showing a number which can be formatted by WA

frosty cypress
#
function ()
    local value, color, text, step
    value = aura_env.manacost
    step = aura_env.triggerAmount / 5
    
    if aura_env.config["inverted"] then
        if value > step * 4 then
            color = "FFFF0000"  -- Red
        elseif value > step * 3 then
            color = "FFFFA500"  -- Orange
        elseif value > step * 2 then
            color = "FFFFFF00"  -- Yellow
        elseif value > step * 1 then
            color = "FF00FF00"  -- Green
        else
            color = "FF00FFFF"  -- Cyan
        end
    else
        if value < step then
            color = "FFFF0000"  -- Red
        elseif value < step * 2 then
            color = "FFFFA500"  -- Orange
        elseif value < step * 3 then
            color = "FFFFFF00"  -- Yellow
        elseif value < step * 4 then
            color = "FF00FF00"  -- Green
        else
            color = "FF00FFFF"  -- Cyan
        end
    end
    
    if value >= 1000 then
        text = math.floor(value / 1000) .. "K"
    else
        text = value
    end
    
    return WrapTextInColorCode(text, color)
end
#

I don't know if it's the best way to do it but it works. eddaniLol

frosty cypress
compact hollow
#

You already are

frosty cypress
#

Actually, I've tried to color text via conditions but there is an inverted flag that I don't know how to handle if I use conditions for coloring text, so I went for this solution instead.

compact hollow
#

You carry inverted through to a trigger value too

#

!tsu

paper owlBOT