In CaveX16, I had the messiest file in existance. One of the things this included was a list of blend files that needed to be loaded:
TILE_BLENDS = [ 'Models/UI/Indicators.blend', 'Models/Map/Tile.blend', 'Models/Map/Crystal.blend', 'Models/Buildings/Concrete Pad.blend', 'Models/Buildings/Light Tower.blend', 'Models/Buildings/Entry.blend', 'Models/Units/Miner.blend', 'Models/Units/Resource Transport.blend', 'Models/Units/MiningMachine.blend', ]
Now, this is one way to do it. It worked, but didn’t quite seem right. It’s a list that needs manual maintinance, and as can be seen from it’s name, it got, well, extended beyond it’s initial purpose.
Solution 1: Load everything in a subdirectory
There’s a Models folder, so why not just go through and load every item from in there? What if it is a big enough game that not all levels require all objects, then it becomes a waste of time/ram.
Solution 2: Load some objects using method 1 and others by parsing the level file
Have one subfolder for ‘generic’ objects needed all the time. Then have the level file define what addional assets are required (from presumably a different directory).
Solution 3: Each script tells the loader what it requires
This handles different levels easily as you can just call requireObj from when the script is initialized but before the loader runs. This is how things were handled in Simple Six.
Solution 4: Python Meta-magic
Yeah, nope. Not going here. Anything involving magic dictionary lookups, parsing module code etc. I will not consider without an extremely compelling argument.
So how have people handled loading assets in the past, or a I the only person actually using LibLoad in my games?