I’ve added support for mods for my game. Any Python module put in a specific folder is automatically imported on startup. All is fine, except now I’ve written an official mod which allows mod makers to easily add GUI settings of their mods to a single toggable GUI frame. They are not forced to use it, but it greatly simplifies adding GUI settings with helper functions and makes things more organized and simpler for the players.
The problem is since its a mod itself, its imported on startup with the rest of the mods (Python modules), so if there is another mod which has a name which comes before it, it cannot use my mod. I know I could add “0_” or something to my module’s name, but that wouldn’t be very clean and you can’t be very sure someone won’t name his own mod’s modules like that.
So I’m wondering if there’s any way to tell Python to import a module first, by specifying it inside the module itself? I’m pretty sure there isn’t, but who knows?
One solution I thought of is to make a subfolder which would be searched for modules first.
Another one might be merging the mod’s code with the game’s. Don’t want to do that as to not give the impression that it’s the only way to add mod settings.
Why not have a list of all “system” modules that you need to have loaded which will be imported first, before then looking in sub-folders for all your mods and importing those ?
That way you still maintain your base system and only afterwards do you load up subsequent user mods.