Managing Run-Time

If you want to know why am I asking this question, then read this:

After recently learning a bit of Java, I have been sort of in awe about the way run-time is managed. So basically, you have all of your separate classes and module functions wherever the developer wants to put them, but what I really want to get at is how there is a dedicated function for run-time. So only the stuff in the run-time function will happen live in the game (I think that’s how it works.)
So although you can call the run-time function from separate files, it would still make sense to call all your functions and use all of your classes inside of one file (I hope that all made sense).

That being said, my current system for managing a game was has been having one script initialize all of my main modules (The ones that operate during run-time), and then have the children modules’ contain all of the functions.

I’m sorry if I didn’t explain everything correctly, but my question is:

Should I get rid of my system that revolves around initializing modules, and instead run only one script during run-time, and have all of my modules just contain their respective functions.

If you happened to not understand a single word I said, then I am basically asking if I should switch to a system like this:

-- RUNTIME SCRIPT:

-- Example modules
local module1 = require(module1)
local module2 = require(module2)

-- Just calling functions instead of initializing the modules
module1.Function1()
module1.Function2()
module1.Function3()
module2.Function1()
module12.Function2()

It really depends on the framework of the module. If it’s an OOP module then you would probably need to initialise it with module:init or smth. If it’s just a general module to hold some basic functions then you would not need to require it. Example of what I just said:
Let’s say you have a path finding OOP module. You’re going to want to initialise it to supply variables to assign to self. If you have a module just to generate and return RNG results, you don’t need to initialise it since there is nothing to supply

I’d discourage against using modules outside of their intended purpose of being “modular”, and recommend just putting them all in a script, and rather using the modules for heavily repeated code, like maybe a raycast or tweening function

Honestly, I have no idea what your framework idea is meant to accomplish, but regardless, if you have a framework idea and you feel like it would help you manage your code better you should just try it out for a project and see if you come across any downfalls or unforeseen limits that it introduces. That’s how you learn to build systems!

For example, I have my own personal framework that has been going through an iterative process of improvement over -I think- 3 years now, and honestly I can’t live without it anymore, not to mention it got me much more comfortable coding in Lua as I’m pretty much extending the language to meet my demands in addition to mastering Lua specific features like metatables and metamethods (which are honestly so good)

tl;dr just make it and use it see if it works out or if it opens you up for an even better idea