View Single Post
06-05-12, 12:22 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You can find a list of all achievement-related WoW API functions here:
http://www.wowpedia.org/World_of_Warcraft_API#Achievement_Functions

I highly recommend you bookmark the following page, which contains links to the above page and many other helpful references for WoW API functions, events, and more:
http://www.wowpedia.org/Portal:Interface_customization

For your specific question, the function you want is GetAchievementInfo, which takes the achievement ID (the number in the achievement's URL on wowhead.com) and returns lots of information about the achievement. The fourth return value is a boolean (true/false) value indicating whether or not you have completed the achievement.

For example, this command:
Code:
/run local _, name, _, completed = GetAchievementInfo(4826) print(string.format("%s is %s.", name, completed and "complete" or "not complete"))
...will print "Level 85 is complete." if you've completed the Level 85 achievement or "Level 85 is not complete." if you haven't.

Really, though, I can't see this being very useful. You should already have a general idea of which achievements you've completed, and if you're not sure, it's probably faster to just find it in the Achievements window than to go find its ID number and use a /run command.

Also, there are plenty of addons that will show you whether you've completed an achievement when you're looking at a tooltip for the achievement (eg. if you click on the achievement link in chat).

If you're looking for ways to see if another player (not yourself) has completed an achievement, you would need to use the the inspect API, not the achievement API. However, as the inspect API is very complicated, very fragile, and somewhat buggy, I would absolutely not recommend trying to work with it for a beginner, and am not going to provide any help with it. I'd suggest using an addon like Examiner for this.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote