Need advice on splitting program into multiple files
Posted: Wed Aug 05, 2020 11:53 pm
Hi,
I'm just starting out with Love2D, and before now I've never worked with multiple lua files in one program, so I need a bit of advice.
I understand that the most common use of separated files is for OOP. However, I'm currently working on a set of functions that manage the window / screen, and I wanted them to all be in their own file (window.lua). Because I want to use these functions and tables outside of this file, none of them can be local. I don't know exactly why, but I've seen online that making everything global is bad practice.
The only solution I can think of is to throw all of these functions/tables into a table, then load the file using require(). But I can't believe that this is the best solution - it makes everything really messy and confusing.
Does anyone know of a better solution?
Thanks
I'm just starting out with Love2D, and before now I've never worked with multiple lua files in one program, so I need a bit of advice.
I understand that the most common use of separated files is for OOP. However, I'm currently working on a set of functions that manage the window / screen, and I wanted them to all be in their own file (window.lua). Because I want to use these functions and tables outside of this file, none of them can be local. I don't know exactly why, but I've seen online that making everything global is bad practice.
The only solution I can think of is to throw all of these functions/tables into a table, then load the file using require(). But I can't believe that this is the best solution - it makes everything really messy and confusing.
Does anyone know of a better solution?
Thanks