Making a plugin
Plugins are fairly straight forward to develop, as it is just a matter of file execution order and scope. Plugins at their core, just execute code like any other script, they do have some special properties though.
Path load order
In a normal scenario with the default boot loader, plugins will load these file paths in order:
1. /setup
2. / (Root directory)
3. /vgui
4. /entities (Loads as entities)
5. /hooks
6. /items
7. /benches
8. /mixtures
9. /buyables
10. /vendors
Hooks
Similar to how the GM table works, plugins have a global PLUGIN table created to load hooks, for example:
function PLUGIN:PlayerSay(ply,text) print(ply:NameID() .. " said " .. text) end
This would create a new hook for the PlayerSay event.
Metadata
Plugins now have metadata stored to identify which version of the plugin as a way to identify errors in old versions of a plugin.
These values can be set to identify your plugin:
- PLUGIN.Name
- PLUGIN.Desc
- PLUGIN.Author
- PLUGIN.Version
These values can be found in a menu for developers, or in the event of a LUA error, ~~will be supplied in the console for users to create a bug report.~~ these details will be supplied to the endpoint for automated bug reports.