Cannot add an actuator from a non-active controller

so you running a module?

In that case it is not recommended to assign any variables with references to the current controller or object at module level (no indentation).

This is executed exactly once, by the first controller importing this module.
This would be fine as long only ONE controller is doing this.
But if another one imports this module as well the references would be to the other controller/object.

This is much different to a script. While the scripts just dies after execution, the module keeps alive in memory. Each time you reference anything from the module it is exactly the same (Python) object.

How to solve this?
as suggested use GameLogic.getCurrentController() within the function level or transfer it by function parameters.

If you use the module mode of the Python controller the first parameter of the called function is the current controller (regardless how you name the formal parameter):


def myFunc(cont):
  currentObj = cont.owner # accessing the current controller

I’m taking your code as example:

g is always right as GameLogic never changes
c is incorrect when calling any function from another controller
s is incorrect when calling any function from a controller within another scene (overlay scene)
objlist the same as s
o the same as c

BTW: on character variable names is just and does not support the readability of the code. It is recommended to use this in a very small context only (e.g. an index in a loop). Try to goes what “s” means if you have to scroll up 2 pages or more (string? stapel? shoe? scene? saturation? saturn?).

1 Like