0

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?

Paul Manta
  • 30,618
  • 31
  • 128
  • 208

2 Answers2

1

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)

sbrichards
  • 2,169
  • 2
  • 19
  • 32
  • Symbolic links are like shortcuts on Windows? – Paul Manta Aug 19 '11 at 07:25
  • kind of, when you call a symbolic link, let's say I make file /home/steven/test.txt I can make a symbolic link to it by doing: ln -s /home/steven/test.txt /home/steven/test , so when I do "cat /home/steven/test" it'll bring up whatever is in test.txt, of course this can work in other directories – sbrichards Aug 21 '11 at 22:59
0

[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.

Paul Manta
  • 30,618
  • 31
  • 128
  • 208