diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-04-30 12:01:31 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-04-30 12:01:31 +0400 |
commit | b5b24ee521866637871e7555d4294c0936a0664d (patch) | |
tree | 37634051fe6b01bea895adad4899f75db47187b6 /source/gameengine/GamePlayer | |
parent | 939290b59c52bdd84b9f20083d4dd76ada293ee8 (diff) |
BGE Python sys.path for the blenderplayer and blender
sys.path is the search path for python modules. This is useful so people making games can put all their scripts in a folder and be sure they will always load into the BGE.
for each blend file a scripts directory is added to the path
/home/me/foo.blend
will look for modules in...
/home/me/scripts/*.py
It could also default to look for modules in the same directory as the blend file but I think this is messy.
Added a note in the tooltip about //scripts so its not such a hidden feature.
This works by storing the original sys.path, then adding the paths for the blendfile and all its libs,
when a new blendfile is loaded, the original sys.path is restored before adding the blendfiles paths again so the sys.path wont get junk in it.
One problem with this - when using linked libs the module names must be unique else it will load the wrong module for one of the controllers.
also fixed 2 bugs
- sys.path in the blenderplayer was growing by 1 for every file load in blenderplayer
- the relative path (gp_GamePythonPath), wasnt being set when loading files in the blenderlayer (as I wrongly said in the last commit).
Diffstat (limited to 'source/gameengine/GamePlayer')
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 64e70ce37c3..7c47d2353a6 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -704,10 +704,10 @@ int main(int argc, char** argv) BLI_strncpy(pathname, maggie->name, sizeof(pathname)); BLI_strncpy(G.sce, maggie->name, sizeof(G.sce)); + setGamePythonPath(G.sce); if (firstTimeRunning) { - setGamePythonPath(G.sce); firstTimeRunning = false; if (fullScreen) |