1. #1

    Change A Text-Weakaura's Color Depending On Buff Stacks (Custom Lua)

    Hello!

    Warlock here who wants a text-weakaura that shows the current cast time of Chaos Bolt (which I have gotten to work) but also wants the color of this text to turn red whenever I have more than 2 stacks of the Backdraft buff on me.

    I have made a Weakaura that is a text-type, the display text is %c (since it is returned from the custom function) which looks as follows:

    function()
    local _, _, _, _, _, _, currentCastTime, _, _ = GetSpellInfo(116858)
    local actualCastTime = currentCastTime*0.001
    return (string.format("%.1f", actualCastTime))
    end

    And this weakaura is set to trigger all the time when I am alive, so it updates constantly. It works as it should, it shows a digit 2.4 and this changes to for example 1.8 when I get Heroism on me. On top of all this I want the textcolor of this text-Weakaura to change to a different color (red) whenever I have 2 or more stacks of the buff Backdraft on me.

    To do this I have in the Animations tab under Main picked Custom Function, set the color to red and entered this custom code:

    function(progress, r1, g1, b1, a1, r2, g2, b2, a2)
    local stacks = select(4, UnitBuff("player","Backdraft"))
    if stacks > 2 then
    return r2, g2, b2, a2
    else
    return r1,g1,b1, a1
    end
    end

    In my mind this ought to work - and funnily enough it does if I use the same Backdraft-function on for example a Progress bar for one of my procs, the progress bar successfully changes color to red depending on my Backdraft stacks - what I can't figure out is why this wont work on a text-Weakaura (but does work on a progress bar-Weakaura).

    The Weakaura itself:
    daKHfaGiPWLaGgfq1PaIvrqLzPQUfPQDrqgMu1XqyzI0ZiIPHexJaBte9ne14auNdOCpG0(KIIdIi0cjsperAJsr(i IiNeruRKuEjaOzkfL2jr5NeugkaWsbq9uqtLQ6Qic(kbvTxu)LQmyOdtYIbKhl0KjvUSkBMqFgjnAIQtJuVweA2cUT uz3I63uz4sPLtXZP00LCDvz7aiFxkQmErW5bO1lfvTFLzc2NHDmuhd1X(m09QaD(yGyOOlxq6M)yzeuyy0fCg2NLrW njGCAAAAp5Ej9eeGLsHf1lqcltclRNlgQJ22gua6FjumeaJtJHXNTCD(xcfdN20eF5yr7YGdY0goC4WGlQcd9(d9(d 9(d9(d9(d9(dJpJ5YfPkB5t3D)HE)HEdbDijDfS9cbsol6aNGijWcagKPnC4WHbxufgQI1tfivzlF6UBiOdJpJ5YfP kB5t3DcxVq99etB4WHdnx9m5HGBldDMQqIotNQaVbakeHyJ)qvSEQaPkB5t3DGaY0goC4WHdho8Y6yOkt3PkAxM9zy NIoZ(mSaS9yy8zlxhdBnN9kgQcTYvaGxWEm8zpVOl4mSuggDbNXhW2JHXNTCDmm6codjXnjiPacbKt23NcgzkKP0ZI 6fqMHrxWzA6LJm0C1ZKhk(YXI2LbV14OAoR9p0q8hsL4peiI)qfXFOj9pKA6FiqP)HQuqM2q96hoCyWfvHHa9ef9YQ UBiOdBivftuNrjwnM2WH61pCyWfvHHEFVV3p6E56799(xcT0MZ(hEvCiOdjHmDj9jkcEJ2GcWZ04peONOOxw1DGmTH dhom4IQWqBPIjAhc6q7fUyboL)qsitxsFIIG3OnOa8mn(nKQIjQZOeRgGaY0goCOE9ddUOkm0wQyI2HGom6E5AAdho CiT4qBPIjAhckOdthwYV80goC4WHdho0C1ZKhAs)dPM(hcu6FOkDAdhoC4fS3WPnC4WHdhoCO5QNjp0q8Ps8bI4pur mTHdho8Y6M2L1nTPnTPnTPXWOl4mamlJGHrxWzirwgbdJUGZiLL1ZfxmSm0uPEg2NHfGThdTLQEwg2EM4Ll5NkuYzy pdF2Z7LPlwkdF5dGUCXq1RCm8zpV2ZeVCj)uHsolLHTNjE5s(PcLCpx7zuLZWWMHlgAoQ0USpGThdRlHIHnhTUso3u YKsskOxcfYP9esKqKYI6PamdZVoFdnvQNXYYiyiTogsQCLZk1fksv2YNU7yO8JMQ8IBImyjLqgmYjjskaSEGPamlQN cWmmbHjkAVILPpfmjcrqHmyualLayYcyyWP0X(m8zpVyqzTSugACHJ9zy3lu0SpxCXWN98STxKLYqB7fzFgAPZudhl tcxm8zpVORdivXszymOSw2NHw6m1WXqHNeb4MvyKca5IlgcOWefTxXYKiebfjceqjjWKfWfdTmmvOEHiZqaILrqHON lMb

    Thankful if anyone cant help me figure this out!
    /Pids

  2. #2
    High Overlord Crudor's Avatar
    Join Date
    Nov 2011
    Location
    Berlin
    Posts
    161
    You have to give the custom animation a duration, otherwise it won't work (which duration you enter does not matter in your case).

    ps.: Use the
    HTML Code:
    [CODE] ... [/CODE]
    tags for your code in the future.

  3. #3
    Quote Originally Posted by Crudor View Post
    You have to give the custom animation a duration, otherwise it won't work (which duration you enter does not matter in your case).

    ps.: Use the
    HTML Code:
    [CODE] ... [/CODE]
    tags for your code in the future.
    That did the trick, thank you very much!

    And thanks for the tip!

Posting Permissions

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