Plugin Dependencies
Specifying plugin initialisation order
For plugins that require functionality from another plugin, the dependency system can be used to ensure that all dependencies are initialised before this plugin. They do this by implementing VRPDepends (native) or depends()
(lua).
Plugin dependencies can be specified simply by naming the plugin that this plugin depends on. This can be in the form of the name reported by the other plugin (from its VRPName function), or in the form of the file name (e.g. someplugin
(.lua
)).
For Lua plugins, the use of require
can be used to load external Lua libraries, but should not be used to require other Lua plugins loaded into the application. Instead, use the dependency system, which loads and initialises the required plugins in the correct order.
Example
Consider two plugins, Plugin A and Plugin B. In order to make Plugin B be loaded before Plugin A, A specifies a dependency.
local modname = ...
local _G = _G
module(modname)
function name()
return "Plugin A"
end
function version()
return "1.0.0"
end
function init()
_G.print("Plugin A initialising!")
end
function depends()
return "Plugin B"
end
To specify multiple dependencies, separate each with a comma. For native plugins this should result in a comma separated string. For Lua plugins, the
depends
function can just return multiple strings:
function depends()
return "Plugin B", "Plugin C"
end