Although this is probably easy to answer like many of my previous topics, how should I be handling shared variables? My framework is divided into modules like this:
They are all siblings currently.
Inside, let’s say the “Loadout” module, I am currently using _G
to access previously defined variables in the loader script:
Constructors to objects are also stored in _G
.
This works fine and all, but is it really the best way to share variables? What if I need access to the constructor of a module that I don’t want to load twice? Do I pass them in as a variable to the module using an initializing function? Or do I give all modules a table that has all these variables that isn’t _G
? Maybe something else?
All help is appreciated. Feel free to ask any questions.