PhysFS and Python embedding

348 Views Asked by At

I am writing a game engine and I'd like it to have Python scripting as well as support for mods using PhysFS.

My game data is stored something like this:

  • /
    • native
      • scripts
      • sprites
      • ...
    • mods
      • mymodname
        • scripts

What I want is for the mod scripts to be able to 'import' the native scripts as if they were in the same directory. Is something like that possible using PhysFS?

2

There are 2 best solutions below

0
On BEST ANSWER

[I am the same person who asked the question.]

The solution I used eventually was to modify Python's sys.path when my program starts. This does not pollute the game's data directories with symbolic links and is overall much cleaner.

2
On

You could create a symbolic link so that you can link those files/folders are in a higher directory, with PhysFS you can do:

PHYSFS_permitSymbolicLinks()

Then have PhysFS follow your symbolic links, hope this help :-)

EDIT: What I would do is symbolically link /mods/scripts to /native/mods-scripts so that /native/scripts can call mods-scripts (which actually points to /mods/scripts)