There are two options when using a sensor to run a python script (which also makes me wonder why the python option is a Controller and not a Actuator, but I guess that's a separate question).

enter image description here

As far as I can tell, Module runs a function in certain file (specified file.function). Script runs an entire file.

What are the practical differences between the two (assuming they are functionally the same)? What are some example cases where you would want to use one over the other?

The wiki page seems to be down currently, so forgive me if the answer is written right at the top..


1 Answer 1


These docs explain:

Script Mode

In Script mode, the controller is linked to a script, the whole script will be executed before the logic moves on. Everything in the script will happen at the same frame, if the same value or attribute are changed more than once, only the latest will be visible in the game because of this. If for example the position of an object is changed first to (100.0,100.0,100.0) but later in the same script changed to (0.0,0.0,0.0), then only the (0.0,0.0,0.0) will be visible to the player because the move to (100.0,100.0,100.0) happened on at the same frame.

Module Mode

Since Blender 2.49 the Python module controller was added. Simply choose Module instead of Script on your Python controller drop-down menu. Then you define a function on that module and call that function from the controller. Instead of writing “myScript.py” on the script edit box, you’ll write “myModule.myFunc” on the module edit box. This function will run every time the controller is called. But other functions and variables outside of myFunc’s scope will only run once. This is good for optimizing your code when you want to initiate variables only once then use them later.

The Python module controller supports any number of attributes, this means packages are supported automatically. As well as “myModule.myFunc” you can do “myPackage.myModule.myFunc”, nested packages work too, as does method calls on class instances like: “myPackage.myModule.myInstance.myMethod”. The python controller is passed to the python function as an argument for functions that take one arg.

Regrettably the 2.6x docs miss this info.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .