All the methods listed below are to be called on your namespace object. For information on how to register a namespace object, see here.
achievementNamespace:RegisterAchievement(id, name, desc, icon, criteria, category, prevAch, nextAch)
id number Numeric ID for your achievement. Needs to be unique within your namespace. Used to address your achievement within the namespace's methods.
name string String used as the name of your achievement. Will be used to represent the achievement to the user (achievement UI, tooltips, links, tracking, etc.) Can contain most characters. The pipe character (|) is prohibited.
desc string A description of your achievement. Displayed in the achievement UI and tooltips. Also used in the achievements tracker for achievements without criteria.
icon string Path to a texture to use as the icon for your achievement. Used in the achievement awarded popup as well as the achievement UI.
criteria table A numerically indexed table containing any number of criteria for your addon. Each index should hold a function that is called when information on that criteria is requested with the namespace object as arg1. Return values of the function should match return values 1-9 of GetAchievementCriteriaInfo, arg10 (criteriaID) will be added by LCA.
category string A string identifying the sub-category of your main category the achievement should be placed in. Must be passed - use an empty string ("") to place the achievement in the root category.
prevAch number or nil The numeric ID of the achievement this should be the follow-up to - used for step-by-step achievements such as "Level 10" -> "Level 20" -> "Level 30" -> "Level 40" etc. The category of the previous achievement will override this achievement's category.
nextAch number or nil The numeric ID of this achievement's follow-up. See prevAch above for details.
Determining the category order
orderTable table Numerically indexed table containing category names in order of appearance. Any unlisted categories will be added after the listed categories. Any non-existant categories in the table will be ignored.
Re-generating the category listing
This function will calculate and cache the list of achievements to display (hiding all but the latest completed and first non-completed achievement for achievement "chains", for example) and cache this list. This function should be called once you're finished registering all your achievements. If this function is not called after your achievements are registered, it will be called the first time the category is opened and will require another click of the category button for the category to be expanded.
Awards an achievement specified. Fairly simple.
Checking for achievement completion
local hasCompleted = achievementNamespace:HasAchievement(id)
Returns a boolean indicating whether or not the achievement specified has been completed.
LCA provides achievements an unlimited number of boolean states they can save, stored in a bitwise variable. Each boolean state is identified by its index and can be read/modified using these methods:
Reading the achievement memory
local isSet = achievementNamespace:ReadAchievementMemory(avID, index)
avID number Numeric achievement ID of the achievement whose memory you want to access. index number The numeric index of the boolean state you want to read.
isSet boolean or nil Indicates the boolean state read.
Modifying the achievement memory
avID number Numeric achievement ID of the achievement whose memory you want to access. index number The numeric index of the boolean state you want to modify state boolean or nil The state to set the state to. nil and false are considered equivalent.
Table of contents
- 1 Registering achievements
- 2 Determining the category order
- 3 Re-generating the category listing
- 4 Awarding achievements
- 5 Checking for achievement completion
- 6 Achievement memory
- Date created
- Oct 22, 2011
- Last updated
- Oct 23, 2011