1. #1

    WA custom text for explosive shot charges

    Hey, so I'm extremely new to coding in lua, and was trying to make a custom text for my hunter to track the number of charges left during lock and load. First of all, I'm wondering if it doesn't specifically register as charges? because the stacks counter doesn't work, secondarily my code looks like this

    Code:
    function()
        local charges, _, _, _, = GetSpellCharges("Explosive Shot")
        return (charges)
    end
    but I feel like I'm doing something wrong, and it returns error messages and such

  2. #2
    Deleted
    I don't think the spell has charges with lock and load. I'm not really sure but whatever it is, maybe try it like this:

    Create two icon auras, both track the Cooldown Progress(Spell) of Explosive Shot.
    One of them only shows when it's on cooldown and is desaturated in the display options.
    The other one shows when it's off cooldown and is not desaturated. Place both in the same spot.
    Then make a third Aura (text) and place it at the same spot again, trigger it off of the Lock and Load buff and the
    display options show the stacks. The number of the text aura should always show on top of the icon which shows
    you that it is off CD.

    I know it's not exactly what you want but maybe it's enough?

  3. #3
    Edit:

    After taking a second look: There is one comma too many at the end of your definitions, which will result in an error.

    Old Post:

    I am guessing that Explosive Shot does not have charges but the buff Lock And Load has stacks, which you would track like this:

    Code:
    return select(4,UnitBuff("player","Lock and Load")) or 0
    Otherwise post the errors you get.

    ps.:

    Your line

    Code:
    local charges, _, _, _, = GetSpellCharges("Explosive Shot")
    is equal to

    Code:
    local charges = GetSpellCharges("Explosive Shot")
    The "_" is a valid variable name, for which you just decide not to use it after its definition. You can just omit it in your case. The parentheses in your "return" line is also unnecessary. Simplifying you could just write

    Code:
    return GetSpellCharges("Explosive Shot")
    Last edited by Crudor; 2015-01-31 at 02:01 PM.

  4. #4
    thanks a ton for the help!,
    Code:
    return select(4,UnitBuff("player","Lock and Load")) or nil
    worked, though now I'm wondering what it would take to always add 1 to the number, so with lock and load it shows 3, without it shows 1.

    I tried to make it into a variable
    Code:
    chargevariable = select(4,UnitBuff("player","Lock and Load")) or 0
    and then return chargevariable + 1 but it didn't work and I assume that's way too simplistic an attempt?

  5. #5
    You want `local changevariable`, and `return changevariable + 1` should do fine. Was there some sort of lua error or something?

    Also:

    Code:
    return (select(4,UnitBuff("player","Lock and Load")) or 0) + 1
    Alternately, make it a string before returning it:

    Code:
    return tostring((select(4,UnitBuff("player","Lock and Load")) or 0) + 1)

  6. #6
    So the current code looks like
    Code:
    function ()
        if UnitBuff("player","Lock and Load")
        then return (select(4,UnitBuff("player","Lock and Load")) or 0) + 1
        else return nil
        end
    end
    What I'd like to do now is set it so that if the buff is 3 then it will be purple, if it's 2 then it will be green. I'm assuming that I'd have to create a variable that = stacks of lock and load+1, then say if variable == 3 return purple, and so on. What I don't know is how I could designate the color for the text to turn? especially considering it's inside weakauras custom text editor. Is this possible?

    also what would be the benefit of making it a string?

Posting Permissions

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