API Documentation - WeakAuras/WeakAuras2 GitHub Wiki
API Documentation
This is a documentation of the public-facing API that WeakAuras supports. Functions listed here which do not behave as advertised are worthy of a bug ticket. Since WeakAuras is in fairly rapid development, the API should not be considered frozen. However, we make every reasonable effort to ensure that updates are backwards compatible.
Commonalities
Every API which WeakAuras publishes will, unless otherwise specified, use its first and second return values to give information about the success or failure of the API call.
status, msg = WeakAuras.SomeAPI(...)
status
is a simple indication of whether or not the API call succeeded. If it is truthy (either a literal true
, or some other API-specific value), then the API finished sucessfully. If status
is nil
, then the API call failed to execute, and msg
will be a string value with an explanation of the problem. If status
is false
, then the API call successfully executed, but there are one or more warnings, which can be read in msg
.
assert(WeakAuras.RegisterDisplay()) -- assertation failed! "Addon must be a string value."
GenerateUniqueID
Generates a unique string of characters. This API is intended for creating a unique identifier for display data.
data.uid = WeakAuras.GenerateUniqueID()
Parameters
- None
Return Values
GenerateUniqueID returns a representation of an 11 digit random number in base-64. No checking is done to ensure that it actually is random, since there are about 73 quintillion possible values for uid.
Import
Prepares aura data to be imported into WeakAuras.
WeakAuras.Import(inData, [target], [callbackFunction])
Parameters
-
inData
- Payload to be imported. Must be a table, either raw or compressed and encoded using LibDeflate. Table must be of the following format:
inData = { d = {...}, -- required: primary aura data c = { {...}, {...}, ...} -- optional: array of child aura data }
-
target
- Optional; may either be a table which exists in the database already, or a uid which exists in the database already. If
target
points to an aura which already exists, then the payload will be processed as an update for the existing aura. Otherwise, the database will be searched for a possible match.
- Optional; may either be a table which exists in the database already, or a uid which exists in the database already. If
-
callbackFunction
- Optional; function to be called on completion of import process. Returns the ID of the Aura if import was succesful.
Return Values
WeakAuras.Import
returns whether or not it successfully processed the payload and opened a tooltip for the user to begin the installation. If the first return value is not true
, then the second return value will be a string explaining the problem found.