One-way requiring...
Posted: Thu Aug 13, 2015 11:57 pm
Not too sure how to word this one without it sounding weird.
In my game, I have a ton of individual entity files, as many of you do. These are all required by main.lua so they can be manipulated and put into different pre-programmed levels. A side-effect of this is that every file required by main.lua also requires the rest of main's required files as well.
This makes me nervous on some fronts, as I could easily modify an entity's value from another entity without realizing it. I was wondering if there was a way in Lua to do a sort of "one-way require", or make it so that required files don't also require everything else required in main.lua. It would mean a little extra work on my end, putting require statements in front of every entity file, but it would be worth it so that I don't create unnecessary bugs without knowing it...
Not too sure if this even exists. If it's possible, that would be awesome.
In my game, I have a ton of individual entity files, as many of you do. These are all required by main.lua so they can be manipulated and put into different pre-programmed levels. A side-effect of this is that every file required by main.lua also requires the rest of main's required files as well.
This makes me nervous on some fronts, as I could easily modify an entity's value from another entity without realizing it. I was wondering if there was a way in Lua to do a sort of "one-way require", or make it so that required files don't also require everything else required in main.lua. It would mean a little extra work on my end, putting require statements in front of every entity file, but it would be worth it so that I don't create unnecessary bugs without knowing it...
Not too sure if this even exists. If it's possible, that would be awesome.