See the Python reference of this logic brick in
The Python controller runs a Python script when a sensor triggers the controller. This Python script can interact with the scene or logic bricks through Blender’s API.
A Python script can either run as an entire file or a single module.
A file must be added in the Text editor, and is identified simply by its name, not its path.
Names are case sensitive. Modules are identified by the file name without the extension followed by a
and then the name of the module. For example:
def myModule (): print("Go Open Source!");
The function can be accessed as
myscript.myModule, which will run
print("Go Open Source!");
every time the controller is triggered.
The entire file can be run by setting the type to Script and setting the name to myscript.py.
Parts of the Python Controller¶
Specifies whether it is a module or entire file.
The name of the file to be loaded.
- D (Use Debug)
Continuously reloads the file.
See standard controller parts for descriptions of the remaining options.
For more information on the Python API, see:
This chapter for more Game Engine related API.