- 0 Talk
-
Dongle/Module API
< Dongle
The Dongle Module system provides a very simple capability for inheritance and ownership within Dongle addons. Each new module is actually a full-fledged dongle object, with the caveat that its initialization and enable functions aren't called until after its parent, and the disable function is called before it's parent.
This API was introduced with Dongle-1.0
Contents |
DongleObject:NewModule(name[, obj])
Edit
Creates a new dongle object, as a module of this DongleObject.
Arguments
Edit
- name (string) - The name of the dongle object. This must be a unique name in the global dongle registry.
- obj (table) - An optional object to use as the base for the new dongle object.
Returns
Edit
- obj (table) - The dongle object with all injected functions
- name (string) - The name of the dongle object
Behavior
Edit
The module will not have its :Intitialize() or :Enable() methods called until DongleObject's methods have been called. The :Disable() method of the module will be called prior to the :Disable() method of the DongleObject.
DongleObject:HasModule(module)
Edit
Returns true if the given DongleObject has a module matching the given argument, this can be used to get a module by name.
Argument
Edit
- module (string, table) - The name of a module, or the module object itself
Returns
Edit
- module if it exists nil otherwise
DongleObject:IterateModules()
Edit
Returns
Edit
- ModuleIterator (function) - An iterator over the modules of the DongleObject
Iterator Returns
Edit
- name (string) - The name of the module
- obj (table) - The module's object