-
Notifications
You must be signed in to change notification settings - Fork 4
###addon:Disable()
Disables the Addon, if possible, return true or false depending on success.
This internally calls GeminiAddon:DisableAddon()
, thus dispatching an OnDisable
callback and disabling all modules of the addon. :Disable()
also sets the internal enableState
variable to false
####Usage
-- Disable MyAddon
MyAddon = Apollo.GetPackage("Gemini:Addon-1.1").tPackage:GetAddon("MyAddon")
MyAddon:Disable()
###addon:DisableModule(name)
Disables the Module, if possible, return true or false depending on success.
Short-hand function that retrieves the module via :GetModule
and calls :Disable
on the module object.
####Usage
-- Disable MyModule using :GetModule
MyAddon = Apollo.GetPackage("Gemini:Addon-1.1").tPackage:GetAddon("MyAddon")
MyModule = MyAddon:GetModule("MyModule")
MyModule:Disable()
-- Disable MyModule using the short-hand
MyAddon = Apollo.GetPackage("Gemini:Addon-1.1").tPackage:GetAddon("MyAddon")
MyAddon:DisableModule("MyModule")
###addon:Enable()
Enables the Addon, if possible, return true or false depending on success.
This internally calls GeminiAddon:EnableAddon()
, thus dispatching an OnEnable
callback and enabling all modules of the addon (unless explicitly disabled).
:Enable()
also sets the internal enableState
variable to true
####Usage
-- Enable MyModule
MyAddon = Apollo.GetPackage("Gemini:Addon-1.1").tPackage:GetAddon("MyAddon")
MyModule = MyAddon:GetModule("MyModule")
MyModule:Enable()
###addon:EnableModule(name)
Enables the Module, if possible, return true or false depending on success.
Short-hand function that retrieves the module via :GetModule
and calls :Enable
on the module object.
####Usage
-- Enable MyModule using :GetModule
MyAddon = Apollo.GetPackage("Gemini:Addon-1.1").tPackage:GetAddon("MyAddon")
MyModule = MyAddon:GetModule("MyModule")
MyModule:Enable()
-- Enable MyModule using the short-hand
MyAddon = Apollo.GetPackage("Gemini:Addon-1.1").tPackage:GetAddon("MyAddon")
MyAddon:EnableModule("MyModule")
###addon:GetModule(name[, silent])
Return the specified module from an addon object. Throws an error if the addon object cannot be found (except if silent is set)
####Parameters
name
- unique name of the module
silent
- if true, the module is optional, silently return nil if its not found (optional)
####Usage
-- Get the Addon
MyAddon = Apollo.GetPackage("Gemini:Addon-1.1").tPackage:GetAddon("MyAddon")
-- Get the Module
MyModule = MyAddon:GetModule("MyModule")
###addon:GetName()
Returns the real name of the addon or module, without any prefix.
####Usage
Print(MyAddon:GetName())
-- prints "MyAddon"
###addon:IsEnabled()
Query the enabledState of an addon.
####Usage
if MyAddon:IsEnabled() then
MyAddon:Disable()
end
###addon:IterateModules()
Return an iterator of all modules associated to the addon.
####Usage
-- Enable all modules
for name, module in MyAddon:IterateModules() do
module:Enable()
end
###addon:NewModule(name[, prototype|package[, package, ...]])
Create a new module for the addon. The new module can have its own embeded packages and/or use a module prototype to be mixed into the module. A module has the same functionality as a real addon, it can have modules of its own, and has the same API as an addon object.
####Parameters
name
- unique name of the module
prototype
- object to derive this module from, methods and values from this table will be mixed into the module (optional)
package
- List of packages to embed into the addon
####Usage
-- Create a module with some embeded packages
MyModule = MyAddon:NewModule("MyModule", "Gemini:Hook-1.0", "Gemini:Event-1.0")
-- Create a module with a prototype
local prototype = { OnEnable = function(self) print("OnEnable called!") end }
MyModule = MyAddon:NewModule("MyModule", prototype, "Gemini:Hook-1.0", "Gemini:Event-1.0")
###addon:SetDefaultModulePackages(package[, package, ...])
Set the default packages to be mixed into all modules created by this object. Note that you can only change the default module packages before any module is created.
####Parameters
package
- List of packages to embed into the addon
####Usage
-- Create the addon object
MyAddon = Apollo.GetPackage("Gemini:Addon-1.1").tPackage:NewAddon("MyAddon")
-- Configure default packages for modules (in this example all modules need Gemini:Hook-1.0)
MyAddon:SetDefaultModulePackages("Gemini:Hook-1.0")
-- Create a module
MyModule = MyAddon:NewModule("MyModule")
###addon:SetDefaultModulePrototype(prototype)
Set the default prototype to use for new modules on creation. Note that you can only change the default prototype before any module is created.
####Parameters
prototype
- Default prototype for the new modules (table)
####Usage
-- Define a prototype
local prototype = { OnEnable = function(self) Print("OnEnable called!") end }
-- Set the default prototype
MyAddon:SetDefaultModulePrototype(prototype)
-- Create a module and explicitly Enable it
MyModule = MyAddon:NewModule("MyModule")
MyModule:Enable()
-- should print "OnEnable called!" now
See also
- NewModule
###addon:SetDefaultModuleState(state)
Set the default state in which new modules are being created. Note that you can only change the default state before any module is created.
####Parameters
state
- Default state for new modules, true for enabled, false for disabled
####Usage
-- Create the addon object
MyAddon = Apollo.GetPackage("Gemini:Addon-1.1").tPackage:NewAddon("MyAddon")
-- Set the default state to "disabled"
MyAddon:SetDefaultModuleState(false)
-- Create a module and explicilty enable it
MyModule = MyAddon:NewModule("MyModule")
MyModule:Enable()
###addon:SetEnabledState(state)
Set the state of an addon or module This should only be called before any enabling actually happend, e.g.
in/before OnInitialize
.
####Parameters
state
- the state of an addon or module (enabled=true, disabled=false)
###GeminiAddon:GetAddon(name, silent)
Get the addon object by its name from the internal GeminiAddon registry. Throws an error if the addon object cannot be found (except if silent is set).
####Parameters
name
- unique name of the addon object
silent
- if true, the addon is optional, silently return nil if its not found
####Usage
-- Get the Addon
MyAddon = Apollo.GetPackage("Gemini:Addon-1.1").tPackage:GetAddon("MyAddon")
###GeminiAddon:IterateAddonStatus()
Get an iterator over the internal status registry.
####Usage
-- Print a list of all enabled addons
for name, status in GeminiAddon:IterateAddonStatus() do
if status then
Print("EnabledAddon: " .. name)
end
end
###GeminiAddon:IterateAddons()
Get an iterator over all registered addons.
####Usage
-- Print a list of all installed GeminiAddon's
for name, addon in GeminiAddon:IterateAddons() do
Print("Addon: " .. name)
end
###GeminiAddon:NewAddon([object ,]name, configure[, dependencies [, package, ...]])
Create a new Gemini:Addon-1.1 addon.
Any packages you specified will be embeded, and the addon will be scheduled for its OnInitialize
and OnEnable
callbacks. The final addon object, with all packages embeded, will be returned.
####Parameters
object
- Table to use as a base for the addon (optional)
name
- Name of the addon object to create
configure
- Boolean or string, non false values indicate a Config button will be added to the ESC/Options window
- boolean - The button will have the name of the addon
- string - The button will have its name set to this string
dependencies
- Optional able that contains a list of packages and addons that this addon depends on
package
- List of packages to embed into the addon
####Usage
-- Create a simple addon object
MyAddon = Apollo.GetPackage("Gemini:Addon-1.1").tPackage:NewAddon("MyAddon", false, {}, "Gemini:Hook-1.0")
-- Create a Addon object based on a pre-existing object
local MyObj = { Foo="Bar", Baz = true }
MyAddon = Apollo.GetPackage("Gemini:Addon-1.1").tPackage:NewAddon(MyObj, "MyAddon", false, {}, "Gemini:Hook-1.0")