Citrus Loader - A basic module loader

Citrus Loader


What CL

Citrus Loader is a “Module Loader” inspired by chickynoid’s mod system and Suphi’s module tutorial, it automatically loads modules provided to be accessible from anywhere in the game, it requires them and initializes them.

What does it do

In a nutshell sometimes we end up requiring over and over again the same modules from multiple places and it gets tiring to do this, additionally this is meant to be used for single script architecture, where 1 script starts loading all the code for the game, we can load it in order to have more control of how our structure works.

Is this a framework

This is not a framework, My intention isn't for people to use this for their games either, I posted this so people could take a look at an example of how to build a module loader for single script architecture.

How does it work

Drop the module preferably into ReplicatedFirst, require it and call CitrusLoader.Initialize()

image


Create your module categories, You can also set the name of the function that retrieves modules from that category.


Set up your directory where all the modules will be placed, Shared directory is used on both client and server.

image

You can additionally set up a number attribute called “Priority”, to define which modules load first, Higher number = Lower priority, Also a boolean attribute called “Enabled” to prevent or allow module to be loaded.
image


To get your module simply call on the global table the name of the function to retrieve a module from a category and pass it’s name as an argument.

Example: _G.GetMod(“Particle”)


Thats it, This really isn’t super impressive, and im sure the code could be way better, but I thought it would be neat to post this.

Download

CitrusLoader1.0.lua (4.2 KB)

2 Likes