LibInspect

The goal of this library is to provide a universal way to inspect players that doesn't compete with other addons. This library with achieve this by doing asynchronous requests.

In order to use the addon you will need to first load it as a library, then lib:AddHook('addonName', 'what', function(guid) YourFunction(guid, data); end); It will then only request the type of information for addons that have registered. For example what = items it will only run NotifyInspect() and get data.items , or what = {items,talents} then will return data.items and data.talents. 'what' will also include honor and arena information, and maybe more when I get in game and play around with it.

Then when you want to make a request lib:RequestData('what', target, force) or lib:RequestItems(target, force) where force will ignore cached data. It will return caninspect, cached, refreshing where CanInspect() is if fresh data is posable, cached is bool if there is cached information and refreshing is if a NotifyInspect() was sent out.

Speaking of cached data, the lib will store localy old inspect information. This will allow for faster retrevial. The max age that information will be stored is set by lib:MaxAge(seconds); where the lowest settng by any addon will win out.

The lib will try to not break the inspect window as well as try and fix a few issues in the default blizzard inspect.

Documentation

Supported Types

  • all - use sparingly
  • items - returns a table of items
  • honor - not yet
  • talents - not yet
  • achivements - not yet

Methods

success = LibInspect:AddHook('MyAddon', type, function(guid, data, age) YourFunction(guid, data, age); end);

maxAge = LibInspect:SetMaxAge(seconds); default 1800

itemQuantity = LibInspect:SetRescan(items); default 10

caninspect, unitfound, refreshing = LibInspect:RequestData(type, target, force); or LibInspect:Request_Type_(target, force) ex. LibInspect:RequestItems(...)

Callbacks/Hooks

When the data is ready you YourFunction(guid, data, age) will be called

guid = UnitGUID(); -- use this to tie it to the inspect request

data = false; -- Nothing was found/error
or
date =  {
    items = {
        1 = itemLink, -- the result of GetInventoryItemLink("unit", 1);
        2 = itemLink,
        ...
        19 = itemLink,
    },
    honor = ...,
    talents = ...,
    achivements = ...,
};

age = ##; -- how old in seconds the data is

You must login to post a comment. Don't have an account? Register to get one!

Facts

Date created
Dec 01, 2011
Last updated
Aug 29, 2012

Author