First, add LibMultiAccountSets (LMAS) as a dependency in your addon's manifest:
## DependsOn: LibMultiAccountSets>=14
The library can be accessed via the LibMultiAccountSets
global variable, and it is recommended that you localize it for usage; for example:
local LMAS = LibMultiAccountSets
After a character logs on, LMAS will scan the player's item set collection. However, this initial scan is delayed until 1.5s after the completion of the initial load screen because the in-game APIs do not reliably report item set collection information until they are themselves fully initialized. All LMAS functions will work prior to the completion of this initial scan, but the reported data for the current account may be potentially inaccurate.
If your code requires accurate access to the current account's data as soon as possible, you could register a callback for LMAS.EVENT_INITIALIZED
. For example:
LMAS.RegisterForCallback("InsertYourAddonNameHere", LMAS.EVENT_INITIALIZED, function( ) -- do stuff end)
Note: Callbacks for LMAS.EVENT_INITIALIZED
that are registered after LMAS has completed its initial scan will not fire; it is thus recommended that LMAS.EVENT_INITIALIZED
callbacks be registered prior to the completion of the initial load screen.
LibMultiAccountSets 3.0.0 (API version 12) introduced new server-aware functions that allow addons to access data that had been collected for a foreign server. These new functions are suffixed with Ex
and have server
as their first parameter. If the server
parameter is nil
, the current server will be assumed. These new functions otherwise behave identically to their original non-Ex
counterparts. The non-Ex
functions, which still exist to maintain compatibility with existing users of LMAS, are implemented simply as calls to the new server-aware Ex
functions with nil
server parameters.
The following are the new server-aware functions:
LMAS.GetNumItemSetCollectionSlotsUnlockedForAccountEx LMAS.IsItemSetCollectionSlotUnlockedForAccountEx LMAS.IsItemSetCollectionPieceUnlockedForAccountEx LMAS.GetItemReconstructionCurrencyOptionCostForAccountEx LMAS.IsItemSetCollectionItemLinkUnlockedForAccountEx LMAS.GetLastScanTimeEx LMAS.GetRawDataEx LMAS.SetRawDataEx
Item collection and trade eligibility status
LMAS.ITEM_UNCOLLECTIBLE -- Not a collectible set item LMAS.ITEM_COLLECTED -- Collected by the specified account LMAS.ITEM_UNCOLLECTED_TRADE -- Not collected by and tradeable with the specified account LMAS.ITEM_UNCOLLECTED_NOTRADE -- Not collected by and not tradeable with the specified account LMAS.ITEM_UNCOLLECTED_UNKTRADE -- Not collected by the specified account, with unknown trade eligibility
Callbacks
LMAS.EVENT_INITIALIZED -- Fired when LibMultiAccountSets has completed its initial scan LMAS.EVENT_COLLECTION_UPDATED -- Fired when item set collection data has been updated, either by the player having collected something or data for other accounts have been imported
The following functions mirror (and behave identically to) functions found in the in-game API, except with added server
and account
parameters:
-- In-game counterpart: GetNumItemSetCollectionSlotsUnlocked LMAS.GetNumItemSetCollectionSlotsUnlockedForAccountEx( server, account, itemSetId ) LMAS.GetNumItemSetCollectionSlotsUnlockedForAccount( account, itemSetId ) -- In-game counterpart: IsItemSetCollectionSlotUnlocked LMAS.IsItemSetCollectionSlotUnlockedForAccountEx( server, account, itemSetId, slot ) LMAS.IsItemSetCollectionSlotUnlockedForAccount( account, itemSetId, slot ) -- In-game counterpart: IsItemSetCollectionPieceUnlocked LMAS.IsItemSetCollectionPieceUnlockedForAccountEx( server, account, pieceId ) LMAS.IsItemSetCollectionPieceUnlockedForAccount( account, pieceId ) -- In-game counterpart: GetItemReconstructionCurrencyOptionCost LMAS.GetItemReconstructionCurrencyOptionCostForAccountEx( server, account, itemSetId, currencyType ) LMAS.GetItemReconstructionCurrencyOptionCostForAccount( account, itemSetId, currencyType )
If server
is omitted (nil
), the current server is assumed.
If account
is omitted (nil
), the current account is assumed.
Determine if an item link is collected:
LMAS.IsItemSetCollectionItemLinkUnlockedForAccountEx( server, account, itemLink ) LMAS.IsItemSetCollectionItemLinkUnlockedForAccount( account, itemLink )
If server
is omitted (nil
), the current server is assumed.
If account
is omitted (nil
), the current account is assumed.
Get the list of accounts for which data is available on the current server:
LMAS.GetAccountList( excludeCurrentAccount )
If the optional excludeCurrentAccount
parameter is true
, the current account will be excluded from the list; i.e., a list of other available accounts.
The return is an alphabetically-sorted list of @account names.
Get the list of servers and accounts for which data is available:
LMAS.GetServerAndAccountList( alwaysIncludeCurrentAccount )
If the optional alwaysIncludeCurrentAccount
parameter is true
, the current account will be included even if the user has added the account to the exclusion list in the settings.
The return is a list of tables, with the current server sorted to the front; each table entry has the following members:
server
: the name of the serveraccounts
: a list of @account names for the server, with the current account sorted to the front and the rest sorted alphabeticallyDetermine the collection and trade eligibility status of an item on the current server:
LMAS.GetItemCollectionAndTradabilityStatus( accounts, itemLink, itemSource )
An item can be specified using either itemLink
or itemSource
; if itemLink
is supplied, itemSource
can be nil
and vice-versa.
itemLink
is an item link string.itemSource
is a table containing the bagId
, slotIndex
, who
, tradeIndex
, and/or lootId
keys.The behavior of the function varies based on the accounts
parameter:
accounts
is a string containing a single @account name, the return is one of the LMAS.ITEM_*
constants.accounts
is a list of @account names or if it is nil
(all available accounts), then the return is either LMAS.ITEM_UNCOLLECTIBLE
if the item is uncollectible or a table with @account names as keys and their respective statuses (as LMAS.ITEM_*
constants) as values.Determine when an accounts's item set collection was most recently scanned:
LMAS.GetLastScanTimeEx( server, account ) LMAS.GetLastScanTime( account )
If server
is omitted (nil
), the current server is assumed.
If account
is omitted (nil
), the current account is assumed.
The return is a Unix-style timestamp.
Accessing the raw bitfield data for an item set:
LMAS.GetRawDataEx( server, account, itemSetId ) LMAS.GetRawData( account, itemSetId ) LMAS.SetRawDataEx( server, account, itemSetId, slots ) LMAS.SetRawData( account, itemSetId, slots )
If server
is omitted (nil
), the current server is assumed.
If account
is omitted (nil
), the current account is assumed.
Warning: The use of these functions is not recommended.
Callbacks:
LMAS.RegisterForCallback( name, eventCode, callback ) LMAS.UnregisterForCallback( name, eventCode )
eventCode
is one of the LMAS.EVENT_*
constants.
Open the LibMultiAccountSets settings panel:
LMAS.OpenSettingsPanel( )