-
Notifications
You must be signed in to change notification settings - Fork 1
Modules
MustBeLeaving edited this page Feb 24, 2026
·
5 revisions
Modules are how you, a user, interacts with MelonLib and its components in a reliable easy way.
They provide 4 key features.
- Resolving load-order issues through a well defined load order
- Incentivizing an (opinionated) well structured project structure
- Meta analysis of code at runtime, although niche it can be quite useful
- Separation of client, shared and server files through prefixes.
If you'd like to get started quickly, clone the module template repository
Otherwise, if you'd prefer not to use the template:
- Create an addon in
garrysmod/addons/ - Inside your addon folder create
lua/melon/modules/ - Inside that folder, create a folder for your module
- Inside your module folder, create a folder called
srcand a file called__init__.lua - Inside
__init__.luapaste the following:
return {
recursive = true,
extras = {}
}
6. That's it!Once your module is made, you can use any MelonLib function or interface immediately.
If you'd like to use MelonLib without a module, use the hook Melon:DoneLoading:Core to monitor when MelonLib is done loading.
Note
If MelonLib is loaded before your addon is, this hook will have already been called. Condense your file loading into one function and call it with the hook and if melon then!