Quantcast
Download
(3 Kb)
Download
Updated: 10/21/14 10:11 AM
Compatibility:
Update 4 (1.4.3)
Updated:10/21/14 10:11 AM
Created:10/21/14 10:11 AM
Monthly downloads:26
Total downloads:808
Favorites:0
MD5:
LibDataBlock-1.0
Version: 1
by: Alisu [More]
LibDataBlock is meant to create a bridge between addons that offer some data the user might want to see on his screen, and viewer addons that show the registered blocks , thus giving user some choice how to see them. For those who are familiar with the concept of lib data broker this shouldn't be new idea and indeed, lib data block is just a port of it for eso on permission of the original author.

To use LibDataBlock in your addon, easiest way is to embed it, as well as LibStub it requires, and then call for it’s instance in the addon.

Code:
local ldb = LibStub:GetLibrary("LibDataBlock-1.0")
API

Code:
ldb:NewDataObject(string name, table/nil dataobject) -> dataobject
Creates and registers a new data object. If table is provided as second parameter, the string keyed values will be used for the new data object. The method also fires callbacks which are registered to listen "LibDataBlock_DataObjectCreated" event.

Code:
ldb:DataObjectIterator()
Iterator to go through all registered data objects which works like pairs().
Lua Code:
  1. for name, block in ldb:DataObjectIterator() do
  2.   ...
  3. end

Code:
ldb:GetDataObjectByName(dataobjectname) -> dataobject
Returns registered data object by name.

Code:
ldb:GetNameByDataObject(dataobject) -> string name
Returns name of the given data object.

Code:
ldb:pairs(string/dataobject dataobject_or_name)
Works as pairs() for data object

Code:
ldb:ipairs(string/dataobject dataobject_or_name)
Works as ipairs() for data object.

Code:
ldb:RegisterCallback(string eventname, function callback)
Is used to register a callback working much like events. The library fires 5 different types of callback events. Apart from the aforementioned data object creation, every time some value is changed in the block, four different events are caused. The callback is function that’ll get called when registered event happens. Next is list of event names, and parameters the functions attached to them will be passed.

LibDataBlock_DataObjectCreated (name, event)
Fired when new data object is registered.

LibDataBlock_AttributeChanged (name, key, value, dataobject)
Fired when any field in any data object is changed.

LibDataBlock_AttributeChanged_<name> (name, key, value, dataobject)
Fired when any field in data object <name> is changed.

LibDataBlock_AttributeChanged_<name>_<key> (name, key, value, dataobject)
Fired when field <key> in data object <name> is changed.

LibDataBlock_AttributeChanged__<key> (name, key, value, dataobject)
Fired when field <key> is changed in any data object. Yes, there is two underscores separating the key from the prefix.

Code:
ldb:UnregisterCallback(string eventName, function callback)
Is used to unregister previously registered callback. The same function has to be passed as parameter so if you are going to unregister an event, the function pointer should be preserved.

Data Specification

The very basic idea of LibDataBlock is based on data objects containing fields that the viewers know to expect and to show. Hence here is some guidelines for what fields should be expected. First and foremost there is type field which defines what sort of block is in question. The rest of the fields and their expectability is determined by what type the block claims to be.

Data Source

type (required) string
“data source”

text (required) string
The text that the block is supposed to show. For example “67/70” for inventory space addon or “Wayrest” for location one.

label string
Can be used as a title in place of name of the object.

icon string
Iconpath the viewers can choose to use to represent an icon accompanying the text.

OnClick function
Function to be executed when the block is clicked.

tooltip control
Control that the viewer can show when, in most usual case, the block is entered with mouse cursor. The viewer will take care of anchoring the control appropriately.


Launcher

type (required) string
“launcher”

icon (required) string
Iconpath the viewers can use to represent a way to launch desired functionality, like your addons interface.

OnClick (required) function
Function to be executed when the block is clicked.

label string
Can be used as a title in place of name of the object.
Post A Reply Comment Options
Unread 11/07/14, 09:41 AM  
neonatura
 
neonatura's Avatar
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 5
Uploads: 1
Scripter ESO Addon LibDataBlock Integration

I have integrated this library into the Scripter ESO Addon as part of the Scripter API provided for creating in-game functions.

Information can be made available to Scripter functions, or retrieved from Scripter functions, by accessing the "Scripter" object's "userdata" structure obtained from LibDataBlock. By default the 'item', 'zone', and 'char' fields of the "userdata" structure are filled in with structure information containing the last obtained item, geodetic/zone location information, and character attributes.

Additional scope inside the "Scripter" object beyond the "userdata" structure may be implemented upon request for specialized external Addon compatibility.

On a seperate note; It would be helpful to create a standardized "Option" object which can share configuration settings between addons. Any feedback on recomended structure definitions or configuration option guidelines would be welcome.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: