1. #1

    WAs: Why doesn't %%n work in a function?

    I noticed %%n works fine in a return "%%n" put into a custom display function. But if in the custom display function I use it for a check in a UnitBuff("%%n", "Buff name") it returns null even if I know for a fact that buff is on that player (and %%n actually reports a specific player name). It even returns null even if I assign local name = "%%n" and I double check that return name works fine!

    Something clear is that an equality check of "%%n" == "String" does not return true even if a return "%%n" and a return "String" appear to show the exact same thing. I wonder if %%n includes invisible formatting that breaks it.
    Last edited by WarcraftMages; 2016-02-18 at 01:03 PM.

  2. #2
    I think you're misunderstanding the variable replacement here. When you create a custom function, the function is actually a Lua string that you provide to WA. WA "compiles" it into a Lua function, then executes the function whenever appropriate. WA uses the return value of the function and can do variable replacement or whatever other processing necessary.

    WA doesn't do variable replacement on the Lua string representing your function before it turns it into a Lua function. So any time you use "%%n" in the body of the function, that is indeed "%%n".

  3. #3
    I understand. It's not easy to understand it if a local string_name = "%%n" can make it appear working in that way if a return string_name returns the final value but I get it, it's only a top-level shortcut at the weakauras level only, it doesn't go through Blizzard's parser as I expected.

    What I do not get is why doesn't Weakauras use an aura_env.name or similar to accomodate a use like that? It seems like an obvious feature in order to avoid re-writing basic auras like getting a simple debuff's information into a custom form just for getting a var for a char name.

    It seems like a good feature request.

  4. #4
    There are some references in the WeakAuras documentation to WeakAuras.CurrentUnit

    Perhaps that will work for you?
    Last edited by quthar; 2016-02-18 at 05:09 PM.

  5. #5
    That sounds promising. It's hard to find documentation on those things.

    That doesn't seem to work in a custom display of a simple aura trigger:

    Code:
        if WeakAuras.CurrentUnit then 
            return GetUnitName(WeakAuras.CurrentUnit)
        end
    Unless I miss how it works.

  6. #6
    It looks like WeakAuras.CurrentUnit is only exposed to the custom function on the actions tab. link

    Sorry, I thought it was available more widely.

Posting Permissions

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