Dongle/Core API

To develop an addon using the Dongle framework you must first ensure Dongle is loaded as part of your addon, or as a dependency, see Dongle/Embedding. You should also know what version of Dongle you are using within your own addon.
==Obtain a local reference to Dongle==
The following code queries DongleStub for the most recent library named "Dongle-Major-Version". You will need to change this name to whichever major version of the framework you are using. This step can be skipped, but I'm including it for clarity.
 local Dongle = DongleStub("Dongle-Major-Version")
==Dongle:New(name[, obj])==
Creates a new dongle object.
===Arguments===
* name (string) - The name of your dongle. This name must be unique in the global dongle registry.
* obj (table) - An optional table to use as the basis for the dongle object. If not provided, a new blank table is created and returned.
===Returns===
* obj (table) - The created (or passed) dongle object with all injected functions
* name (string) - The name of the dongle
===Behavior===
* Initialize - When the first ADDON_LOADED event fires following your creation of the dongle object, your object's :Initialize() method is called if it exists.
*: It is possible to fire off an early ADDON_LOADED by loading another mod. To prevent this, you should only call LoadAddOn in (or after) your Initialize method.
* Enable - At PLAYER_LOGIN, the :Enable() method of your object is called if it exists.
* Disable - At PLAYER_LOGOUT, the :Disable() method of your object is called if it exists.
==Injected functions==
The following sets of functions are injected into any Dongle object:
* Dongle/Module_API - Creating and maintaining modules
* Dongle/Events_API - Easy event registration and callback
* Dongle/Message_API - Custom event registration and callback system
* Dongle/DebugPrint_API - Debug and Print functionality
* Dongle/Database_API - Database system for saved variables
* Dongle/Slash_API - Slash command registration system
Category:Dongle