In theory you would then be able to import any package defined in that directory in your res_mods//scripts/client/mods/mymod.py. For that reason you could, for instance, add res_mods//scripts/client/mods to sys.path. That means that any package you make in the mod directory can't be imported. The exception being directories directly under os.getcwd(), but the working directory is the WoWs installation path, not the mod directory. In python if you want to import some files, they usually need to be findable in entry on sys.path. The _builtin_._import_ has been overwritten by a custom function supplied by the game. The sys.path contains the res/scripts.zip/scripts directory so that modules provided by the game can be imported. The world of warships python mod loader just walks trough res_mods//scripts/client/mods, reads any file ending with. So right now the only practical way to write any python mod is to put it all into one flat file, and I'm wondering if I've overlooked something obvious, or if the WoWs import code is just broken. I believe this has something todo with the modifications that Lesta made to _builtin_._import_ but no matter what I do (sys.meta_path importers, sys.path_hooks, importing via _import_, imp, importlib etc.) nothing works as expected. Next I tried putting my mod files into a zip file, and adding that to sys.path, which is better, now at least upon import the python file gets executed, however the import still returns the sys module instead. pyc was present) or the sys module (if the. I've tried appending a directory to sys.path that would contain some source files and then importing from there, but that didn't work, the module wasn't executed and an empty module was returned (if the. However nobody wants to put all his code into a single flat file, that's just not terribly practical. World of warships seems to support python mods in some way, and I got as far as getting it to load/execute the modfile I have in res_mods//scripts/client/mods. I'm having some trouble with python modding related to importing your own files.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |