I’ve started experimenting with using Notepad++ for scripting with the game engine instead of using the internal text editor so I saved all my scripts in a seperate folder to be edited with it. I’ve found, however, that once the external files are edited and saved they need to be reloaded in the .blend file for the changes to take effect. This becomes a pain when changing multiple text files because each one has to be reloaded even if the entire .blend is reloaded. Is there a way to automatically sync the .blend with external text files to make this easier?
Yeah, use the Module function - assuming your scripts are in the same folder with the blend file, you can use the Module function of the Python controllers to point to the script. For example, if your Player has a Player function in a GameObjects.py script file, you can use GameObjects.Player to run the Player function in the GameObjects file. For more info, check out my blog - the first tutorial deals with using external text files for scripting.
Thanks for the help, I’ve never heard of this before. I tried it out with one of my files and it works, but the console says: “debugging “CharacterAnimation.main”, module for PlayerArmature expect worse performance.” (and I guess ‘worse performance’ means ‘completely unplayable’). Has this happened with you?
Edit: nevermind, I just figured out that that’s what the little button with the ‘D’ on it does. Which means everything else works perfectly and is exactly what I needed. It will surely make scripting alot faster and easier.
The little D is for debugging mode, so you can edit the file while running the game. The changes will take place within the next execution of the Python controller after saving the file.
The module mode is fine, you will recognize that the number of required files might drop dramatically and it executes faster. Keep in mind that the external file has priority over the internal file. (that means before you give your blend away, you should update the internal textfiles ).
The little D is for debugging mode, so you can edit the file while the game is running. The changes will take place within the next execution of the Python controller after saving the .py file.
The module mode is great, you will recognize that the number of required files might drop dramatically and it executes a bit faster. Keep in mind that the external file has priority over the internal file. (that means before you give your blend away, you should update the internal textfiles ).
That’s a cool feature, should be fun to play around with.
When you say the external files take priority over internal, do you mean that they execute first as if they were marked to execute first?
No. I think I used the incorrect words.
If you have module.py in your folder and module.py as internal text block, the internal text block will not be read by the BGE at all.
Exception:
- Python controller in script mode use ONLY the internal scripts. (It is not recommended to mix this modes for one file).
Ok, that makes sense.
Thanks for the info on this, it’s helped a ton already.