-
-
Notifications
You must be signed in to change notification settings - Fork 184
Plugins & Modules
Adonis expects any modules it's loading to return a function containing the module's code to run. Adonis will require the module, set the returned function's environment to a custom one containing all important variables, and will execute the function.
Plugins are loaded without yielding and will be loaded only after all of the core modules are loaded.
Developers can create custom modules for Adonis to load without needing to alter Adonis's MainModule. Simply add modules to Adonis_Loader > Config > Plugins
Server modules should have names starting with "Server: " Client modules should have names starting with "Client: " Example: "Server: CustomChatHandler"
The module's name will be used by Adonis to determine if the module is a client plugin or a server plugin. The modules will be loaded after the "Core" modules finish loading.
Plugins have the same level of access as any of Adonis's "Core" modules. Because of this, plugin modules are free to add, remove, and change whatever they like. It is advised, however, that you avoid removing any tables, functions, or objects and instead replace them with "dummy" alternatives to avoid causing serious errors.
The following is an example server plugin
Lua server = nil -- Mutes warnings about unknown globals service = nil return function() server.Commands.ExampleCommand = { Prefix = server.Settings.Prefix; -- Prefix to use for command Commands = {"example"}; -- Commands Args = {"arg1"}; -- Command arguments Description = "Example command"; -- Command Description Hidden = true; -- Is it hidden from the command list? Fun = false; -- Is it fun? AdminLevel = "Players"; -- Admin level; If using settings.CustomRanks set this to the custom rank name (eg. "Baristas") Function = function(plr,args) -- Function to run for command print("HELLO WORLD FROM AN EXAMPLE COMMAND :)") print("Player supplied args[1] "..tostring(args[1])) end } end
Start | Guides | Tables |
---|---|---|
Home | Creating a theme | The "Service" Metatable |