For a school project, I need to export a exe so that the game we build can be run on other computers without blender or python installed. The way we have made the game is by using :
filename = os.path.join(os.getcwd(), “scripts/PathGetter.py”)
exec(compile(open(filename).read(), filename, ‘exec’))
Now when I export to a standalone, it does not run the scripts at all. Can someone help me with this? I need to include the scripts in some way. But I have not found a way to do so.
That is not the problem. It does that on export. What I mean is my external python files are not found. So in blender there is a trigger that executes the file. But in standalone that wont work
That is a very strange way to do things. You should use python’s import statement, and call a function inside the imported file instead. Or use the logic brick in module mode and reference the function you with to call directly.
Either way, because the file is external, you’ll need to ensure the user get’s the python file along with the game in the same relative path.
The exporters copy all files that are needed to start the game:
application file (blenderplayer + start blend)
necessary libraries to run the blender player (*.dll on windows)
They do not copy any other files as they do not know they belong to the game.
I suggest you export and then manually copy the remaining files (other blend files, external textures and python files) with the exact [relative] folder structure. Be aware the paths inside the blend files should be relative.
Remark: I do not know if the exporters care external textures and so on. It might be as the blendfile links to this files. Python files are different. The blend file does not contain information where they are located.