Allowing modules to access each other?

My question is exactly the title- how do i even go about doing this?? If two modules require each other, theyre not gonna work.

what I was going to do:

every module is required and put in a table
after every module is required, fire the initiate method of each module if it has one and pass a specialRequire function that will act as the regular require unless the module it requires is in the table

but then, I realized if I initiate a module that requires a module, and that module has its own initiate method, and it hasnt been initiated yet, there could be problems

can any1 provide a safe/good way to allow what im trying to achieve?
another question, is there any real problem with just using 1 local script with a bunch of do blocks for “modules” aside from being less organized/harder to find/categorize things? Idk if I’m overthinking things with my issue but thanks for any help.

3 Likes

You’re indeed overthinking it. You can better just require one module by (local) script and then require other modules in that module. It won’t make much of a difference if you want it complicated or not, 1 module needs to be required by a (local) script in order to work and require other modules (even with events in it i think)

Perhaps @Crazyman32 could provide some insight? This is a feature in his game framework.

If you want to look through the framework code yourself, it’s all on GitHub.

1 Like