Download
(6 Kb)
Download
Updated: 05-29-2010 07:22 PM
Updated:05-29-2010 07:22 PM
Created:02-16-2010 08:03 AM
Downloads:2,055
Favorites:3
MD5:
MagicLib-3.0
Version: 3.0
by: Lonny, CBruyland, Lombra

My account is no longer active and it was deleted by request.

I thank everyone for downloading my addons, I stopped playing WoW a year ago, regardless I kept on updating my addons just to keep them up to date.

Best Regards, Lonny.


A simple library that provides a common interface and functionality for addons.

This is a very lightweight library, it promote event-driven programming, and semi object-oriented support of modules.

Detailed documentation can be found inside the library file.

Modules functionality
  • Events management - Easy events registration, and custom events handling.
  • Tasks scheduling - Efficient scheduled callbacks system.
  • Chat message handlers - Provides better print methods.
Library Registration
New() - Creates a new instance of the library.

Returns.
core - (table) The core module which is defined for each instance of magic.
addon - (table) The addon's global namespace/scope. (This is the same table defined by Blizzard for addons, this also provides an access point to the modules API.)
magic - (table) A predefined fresh table. (A good candidate for defining API methods and expose it through a global variable, this also provides an access point to the modules API.)

Usage.
local core, addon, magic = LibStub("MagicLib-2.1"):New()

Here is a small test addon.

Core.lua
Code:
local core, addon, magic = LibStub("MagicLib-2.1"):New()

-- Do some stuff on ADDON_LOADED. (Built-in event.)
core:RegisterEvent("OnLoad", function(self, event)
    self:PrintC(event)
    SLASH_TESTADDON1 = "/testaddon"
    SlashCmdList["TESTADDON"] = function(input)
        -- Trigger custom event.
        self:TriggerEvent("SlashCommand", input)
    end
end)

 -- Do some stuff on PLAYER_LOGIN. (Built-in event.)
core:RegisterEvent("OnEnabled", function(self, event)
    self:PrintC(event)
end)

 -- Do some stuff on PLAYER_LOGOUT. (Built-in event.)
core:RegisterEvent("OnDisabled", function(self, event)
end)

 -- Do some stuff on PLAYER_ENTERING_WORLD. (Blizzard event.)
core:RegisterEvent("PLAYER_ENTERING_WORLD", function(self, event)
end)

-- Global access point 
TestAddon = magic
Module.lua
Code:
local module = TestAddon:NewModule("ModuleName")

-- Do some stuff on ADDON_LOADED. (Built-in event.)
module:RegisterEvent("OnLoad", function(self, event)
end)

-- Do some stuff on slash command. (Custom event.)
module:RegisterEvent("OnSlashCommand", function(self, event, input)
    self:PrintC(input)
end)
3.0 (30-05-10)
+ It's now registered with WTFPL license so ... Do What The **** You Want!
+ Modules were simplified and they no longer carry classes functionality, therefor you can no longer use :NewInstance(...) or inherit unless it's a class.
+ The following APIs were added, check the library for farther details.

:NewClass(name, inherit)
:NewInstance(name, ...)
:IterateClasses()

------------------------------------------------------------------------
2.5 (18-05-10)
+ Removed the config support completely, it was a mistake on my part to include it the first place. :p

------------------------------------------------------------------------
2.1 (01-04-10)
+ Fixed minor bugs.
+ Trying to register ADDON_LOADED, PLAYER_LOGIN, or PLAYER_LOGOUT will result a specific message about the equivalent built-in event you should use instead.
+ The name of the method 'ToColorString' changed to 'ToRGBString'.

------------------------------------------------------------------------
2.0.2 (11-03-10)
+ Reverted the change I made last push, you can now unregister the built-in events! conclusion never code at nights, or rush it, and be dumb.

------------------------------------------------------------------------
2.0.1 (11-03-10)
+ Fixed minor documentation errors.
+ The built-in events can no longer be unregistered.

------------------------------------------------------------------------
2.0 (10-03-10)
+ Added built-in events. (OnLoad, OnEnabled, OnDisabled)
+ It's no longer needed to provide a name to create an instance of the library as the addon name is always used now.
+ When a new instance of the library is created, a new 'Core' module is created by default.
+ Fixed some documentation errors.

------------------------------------------------------------------------
1.2.5 (23-02-10)
+ Fixed a bug in the scheduling system.
+ Made some minor improvements to the scheduling system.
+ The error messages were modified to make them more readable.
+ Made a minor update to the documentation.

------------------------------------------------------------------------
1.2 (20-02-10)
+ Fixed some args check.
+ Fixed some documentation errors.
+ Added a method to register multiple events with a single handler.
+ Added a method to unregister multiple events.
+ The name of the event is now being passed to all event handlers as a second argument!

------------------------------------------------------------------------
1.1 (18-02-10)
+ Fixed the assertion level on some calls.
+ Added binary heap to handle tasks scheduling.

------------------------------------------------------------------------
1.0.1 (17-02-10)
+ Fixed the 'ToColorString(...)' function to return the correct results.
+ Fixed a bug that made custom events shared across all addons.
Archived Files (10)
File Name
Version
Size
Author
Date
2.5
5kB
Lonny
05-18-2010 12:06 PM
2.1
5kB
Lonny
03-31-2010 09:06 PM
2.0.2
5kB
Lonny
03-11-2010 04:07 AM
2.0.1
5kB
Lonny
03-10-2010 11:12 PM
2.0
5kB
Lonny
03-10-2010 03:48 PM
1.2.5
5kB
Lonny
02-23-2010 09:28 AM
1.2
5kB
Lonny
02-20-2010 05:29 AM
1.1.0
5kB
Lonny
02-18-2010 05:08 AM
1.0.1
4kB
Lonny
02-17-2010 02:59 AM
1.0
4kB
Lonny
02-16-2010 08:03 AM


There have been no comments posted to this file.
Be the first to add one.



Category Jump: