Test Doc

Module LibInit

LibInit should make using Ace3 even more easier and pleasant.

Info:

  • Release': 24
  • Author': Alar of Daggerspine

An embeddable library which offer clean methods to build a configuration table instead of directly fiddling wit an Ace options table

Methods

lib:NewAddon ([target], name[, options[, full[, ...]]])

Create a new AceAddon-3.0 addon. Any library you specified will be embeded, and the addon will be scheduled for its OnInitializee and OnEnabled callbacks. The final addon object, with all libraries embeded, will be returned. Options table format:

  • profile: choose the initial profile (if omittete, uses a per character one)
  • noswitch: disables Ace profile managemente, user will not be able to change it
  • nogui: do not generate a gui for configuration
  • nohelp: do not generate help (actually, help generation is not yet implemented)
  • enhancedprofile: adds "Switch all profiles to default" and "Remove unused profiles" do Ace profile gui

Parameters

  • target (table) to use as a base for the addon (optional) (optional)
  • name (string) Name of the addon object to create
  • options (table) options list (optional)
  • full (bool) If true, all available and embeddable Ace3 library are embedded (optional)
  • ... (string) List of libraries to embed into the addon (optional)

Returns

<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span> new addon

Usage:

 --Create a simple addon object
 MyAddon = LibStub("LibInit"):NewAddon("MyAddon", "AceEvent-3.0")

 -- Create a Addon object based on the table of a frame
 local MyFrame = CreateFrame("Frame")
 MyAddon = LibStub("LibInit"):NewAddon(MyFrame, "MyAddon", "AceEvent-3.0")
 -- Create an Addon based on the private table provided by Blizzard Code:
 local myname,addon = ...
 LibStub("LibInit"):NewAddon(addon,myname)

lib:OnLeaveCombat (action[, ...])

Executes an action as soon as combat restrictions lift Action can be executed immediately if toon is out of combat

Parameters

  • action (string|function) To be executed, Can be a function or a method name
  • ... (mixed) More parameters will be directly passed to action (optional)

lib:Wrap (nome)

Returns a closure to call a method as simple local function

Parameters

  • nome

Usage:

local print=lib:Wrap("print")

lib:Is (class, target)

Check if the unit in target hast the requested class

Parameters

  • class (#string) Requested Class
  • target (#string) Requested Unit (default 'player')

Returns

  1. boolean true if target has the requeste class

lib:Parse (msg, n)

Parses a command from chat or from an table options handjer command Internally calls AceConsole-3.0:GetArgs

Parameters

  • msg (mixed) Can be a string (chat command) or a table (called by Ace3 Options Table Handler)
  • n (number) index in command list

Returns

command,subcommand,arg,full string after command

lib:GetItemID (itemlink)

Parses an itemlink and returns itemId without calling API again

Parameters

  • itemlink (string) A sttandard wow itemlink

Returns

<span class="types"><span class="type">number</span></span> itemId or 0

lib:ScanBags ([index[, value[, startbag[, startslot]]]])

Scans Bags for an item based on different criteria

All parameters are optional. With no parameters ScanBags returns the first empty slot

Parameters

  • index (number) is index in GetItemInfo result. 0 is a special case to match just itemid (optional)
  • value (number) is the value against to match. 0 is a special case for empty slot (optional)
  • startbag (number) and startslot are used to restart scan from the last item found (optional)
  • startslot (number) (optional)

Returns

Found ItemId,bag,slot,full GetItemInfo result

lib:Health (unit)

Returns unit's health as a normalized percent value

Parameters

  • unit (string) A standard unit name

Returns

<span class="types"><span class="type">number</span></span> health as percent value

lib:NumericVersion ()

Returns a numeric representation of version. Can be overridden In default incarnation assumes that version is in the form x,y,z

Returns

z+y*100+x*10000

lib:Trigger (flag)

Simulates a configuration variable change.

Generates Apply* events if needed

Parameters

  • flag (string) Variable name

lib:CancelAllCombatSchedules ()

ScheduleLeaveCombatAction Port Shamelessly stolen from Ace2

lib:Popup (msg[, timeout[, OnAccept[, OnCancel[, data[, StopCasting]]]]])

Show a popup Display a popup message with Accept and optionally Cance button

Parameters

  • msg (string) Message to be shown
  • timeout (number) In seconds, if omitted assumes 60 (optional)
  • OnAccept (func) Executed when clicked on Accept (optional)
  • OnCancel (func) Executed when clicked on Cancel (if nill, Cancel button is not shown) (optional)
  • data (mixed) Passed to the callbacl function (optional)
  • StopCasting (bool) If true, when the popup appear will stop any running casting. Useful to ask confirmation before performing a programmatic initiated spellcasting (optional)

Comments

Posts Quoted:
Reply
Clear All Quotes