PulsarLib.Addons
PulsarLib.Addons
is used by all Pulsar addons to allow PulsarLibs core functionality to be extended onto the addon. This
allows for easier development of addons, less code duplication, and a more consistent user and developer experience.
Creating an Addon
An addon must first be created with PulsarLib.Addons.Create
.. This will
create a new addon with the specified name. This function will then return a new AddonHandler object which you can run the following functions on:
AddonHandler AddonHandler:SetFolder( string )
Sets the folder of the addon. This is the folder that the addon's files are located in.
AddonHandler AddonHandler:SetGlobalVar( table )
Sets the global variable for the addon. This should be the same that is defined in your addons files.
AddonHandler AddonHandler:SetPhrases( table )
Sets the phrases for the addon. This is used for the logging prefixes. Look at the example for more information.
AddonHandler AddonHandler:SetOnLoad( function )
A function that is ran when the addon is loaded.
AddonHandler AddonHandler:SetDependencies( table )
Sets the dependencies for the addon. This is a table of addon names and their versions. Look at the example for more information.
AddonHandler AddonHandler:SetRequiredVars( table )
Sets the required global variables for the addon to load. This is a table of global variable names.
AddonHandler AddonHandler:Load( )
Loads the addon. This should be the final function called on the AddonHandler.
Example
PulsarLib.Addons.Create("Example Addon")
:SetFolder("example_addon")
:SetGlobalVar(ExampleAddon)
:SetDependencies({
["pulsar-ui"] = "latest",
["updatr"] = "1.0.0"
})
:SetPhrases({
Brand = {
PulsarLib.Logging.Colours.Brand, "ExampleAddon"
},
BrandPride = {
Color(228, 3, 3), "Ex",
Color(255, 140, 0), "am",
Color(255, 237, 0), "pl",
Color(0, 128, 38), "eA",
Color(36, 64, 142), "dd",
Color(115, 41, 130), "on"
}
})
:SetOnLoad(function()
print("Example addon loaded!")
end)
:SetRequiredVars({
GlobalVariable = true
})
:Load()