1. #1

    Question LUA code to query a player statistic?

    Hello, I would like to please ask some magical LUA code expert to give me the line of code, perhaps as a /script command that can query for a specific statistic on a player and return the result. For example, Total Kills.

    It takes forever to alt-tab out of WoW, load up the player via Armory (especially with funky name characters), click down through all the statistics pages and Ctrl-F find the one value I'm seeking.

    I figure there must be an API mechanism to do it so if someone can just give me the syntax I can play around with it from there.

    Appreciation in advance for any advice.

  2. #2
    The bad news is that you would need an addon to do this, because it involves waiting for an event to fire indicating that you are ready to compare to another player.

    This has the code to turn a stat title into the number for you, by way of the stat ID: http://wow.gamepedia.com/API_GetStatistic -- you need the stat ID, so that code is likely helpful for doing the translation yourself.

    This sets who you are comparing yourself to: http://wow.gamepedia.com/API_SetAchi...ComparisonUnit

    and finally http://wow.gamepedia.com/API_GetComparisonStatistic gives you the comparison stat for the person selected by that set function.

    The bad part is that you can't call that last function until the INSPECT_ACHIEVEMENT_READY event is fired from the server.

    (In theory you could maybe script something that would create a frame, listen for that, and print to the chat window, but... doesn't sound like fun.

  3. #3
    Ah, so the only way to get a statistic on another player in-game is by comparing yourself?

    I had hoped you could query it somehow the way Addons seem to be able to get information about raid experience and arena teams and whatnot.

    Making a /script into an addon is trivial as it's just adding a .toc header file and cut and pasting the script into a .lua file, but I wasn't sure what the "meat" of the code was.

    It sounds like I would have to make a loop that, for each member of the raid, set that person as the comparison target, waited for the inspect event, then compared my kill stat to the other player's kills stat, and save that value to a table, then report the table to display who had killed the most things ever?

    Am I somewhere in the ballpark of how it would work?

  4. #4
    Yeah, that is the only way to do it. I didn't dig into arena stats, which *might* have a different API, and you could maybe check the "WoW API" from those links, but basically that.

    ...and yes, you are in the ballpark for how it would work.

    The worst part, I suspect, is that this sounds like inspecting someone (eg: for gear) which is rate-limited by the game, and annoyingly unreliable if more than one addon tries to do it. Most addons that touch this have a UI that lets them show progress as they scan, who isn't scanned yet, etc, because inspecting is slow. (Again, IDK if this has the same limitation because it is about achievement stats rather than gear, but I wouldn't be surprised if it was the same because it queries the same sort of back-end system on Blizzard's side.)

Posting Permissions

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