简体   繁体   English

PhysFS 和 Python 嵌入

[英]PhysFS and Python embedding

I am writing a game engine and I'd like it to have Python scripting as well as support for mods using PhysFS.我正在编写一个游戏引擎,我希望它具有 Python 脚本以及对使用 PhysFS 的 mod 的支持。

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.我想要的是 mod 脚本能够“导入”本机脚本,就好像它们在同一个目录中一样。 Is something like that possible using PhysFS?使用 PhysFS 可以实现类似的功能吗?

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 执行以下操作:

PHYSFS_permitSymbolicLinks()

Then have PhysFS follow your symbolic links, hope this help:-)然后让 PhysFS 跟随您的符号链接,希望对您有所帮助:-)

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)编辑:我要做的是将 /mods/scripts 符号链接到 /native/mods-scripts 以便 /native/scripts 可以调用 mods-scripts (实际上指向 /mods/scripts)

[ 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.我最终使用的解决方案是在我的程序启动时修改 Python 的sys.path This does not pollute the game's data directories with symbolic links and is overall much cleaner.这不会用符号链接污染游戏的数据目录,并且总体上更干净。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM