1. #1

    [api] How can I print return value of function onto chat window?

    Hi, I have basic question.

    I want to print some return values of a function onto chat window by wow macro.

    the function is UnitDebuff(). In wow-programming, Unitdebuff is defined by....

    ---------------------------------------------------------------------------------------------------------------
    name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3
    = UnitDebuff("unit", index [, "filter"]) or UnitDebuff("unit", "name" [, "rank" [, "filter"]])
    ---------------------------------------------------------------------------------------------------------------

    What I want to do is printing value1, value2, value3 of UnitDebuff("target","corruption") (corruption is just example)

    But, I've never study wow api, so I have no idea how to pick value1,value2,value3 from UnitDebuff(). There are so many return values.

    Please help me.

    Let me know the macro phrase.

  2. #2
    print() is the Lua function that prints to the default chat frame. If you use that function with another function as the only (or last, more precisely) argument, it should print all the return values of the other function.

    WoW also has the /dump slash command which will do a similar thing. The argument after /dump is the Lua expression that you want to print.

  3. #3
    /script local arg1, arg2, arg3 = UnitDebuff("target", "Corruption"); print(arg1,arg2,arg3)
    should work
    Stop searching the truth, and calm down on good fantasy.
    iDementia

  4. #4
    wow, does print() print all return value?

    /run print(UnitDebuff()) is okay?

    - - - Updated - - -

    Ironi//

    arg1,arg2,arg3 is the very value1,value2,value3 of return values of UnitDebuff() ??

    value1,value2,value3 are not just value but specific return value of UnitDebuff.

    (last 3 return values.)

    name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3
    = UnitDebuff("unit", index [, "filter"]) or UnitDebuff("unit", "name" [, "rank" [, "filter"]])

  5. #5
    Field Marshal concatto's Avatar
    Join Date
    Dec 2013
    Location
    Auldrant
    Posts
    52
    Try this:

    Code:
    /script print(select(14, UnitDebuff("target", "Corruption")))

  6. #6
    Quote Originally Posted by Warlockczar View Post
    wow, does print() print all return value?

    /run print(UnitDebuff()) is okay?
    yes, did you not try it?

    Lua vararg functions accept all return values of the last argument. So as long as you don't add any other argument afterwards, e.g. print(UnitDebuff(),extraFunction(),extraVariable), you'll print everything you want.
    Last edited by pnutbutter; 2013-12-28 at 07:09 AM.

  7. #7
    Um...It didn't work.

    I did

    /run print(UnitBuff("target","[any buff]"))

  8. #8
    Quote Originally Posted by Warlockczar View Post
    Um...It didn't work.

    I did

    /run print(UnitBuff("target","[any buff]"))
    Did you use that exact string? [any buff] is not a valid argument for that function.

  9. #9
    Code:
    select(index, ...)
    will return all vararg arguments passed starting at the indexth one.

    In this case, as you want return values 14, 15 and 16, you'd use:
    Code:
    /run print(select(14,UnitDebuff("target","Corruption")))
    UI & AddOns expert | Interface & Macros moderator - My work

  10. #10
    pnutbutter/

    Yes, I put exact spell name and spell ID.

    Treeston/

    I'll do again after work. THX

    - - - Updated - - -

    Thanks for everyone.

    /run print(select(14,UnitDebuff("target","Corruption"))) works very well.

    I think we can fix errors of Affdots(when soul swapping) with this....?

  11. #11
    I like

    Code:
    /dump argument
    Example:

    Code:
    /dump UnitName("player")
    That way you don't have to call the print function, and the /dump functionality also dumps the output of all return values.
    Non-discipline since 2006. Also: fails. "Chakra, when the walls fell"

  12. #12
    High Overlord Pelf's Avatar
    Join Date
    Mar 2008
    Location
    US-Sargeras
    Posts
    108
    Yes, +1 for /dump. Its output isn't as nice as the output of the one they got the idea from, but it's definitely better than print(...).
    Shiboomi of <Riot> on US-Sargeras

Posting Permissions

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