Module GameTypes :: Class SCA_PythonController
[frames] | no frames]

Class SCA_PythonController

PyObjectPlus --+            
               |            
          CValue --+        
                   |        
     SCA_ILogicBrick --+    
                       |    
         SCA_IController --+
                           |
                          SCA_PythonController

A Python controller uses a Python script to activate it's actuators, based on it's sensors.

Properties:

Instance Methods
 
activate(actuator)
Activates an actuator attached to this controller.
 
deactivate(actuator)
Deactivates an actuator attached to this controller.
bool
isA(game_type)
Check if this is a type or a subtype game_type. (Inherited from GameTypes.PyObjectPlus)
    Deprecated
string
getScript()
Gets the Python script body this controller executes.
 
setScript(script_body)
Sets the Python script string this controller executes.
SCA_IActuator
getActuator(name)
Gets the named linked actuator. (Inherited from GameTypes.SCA_IController)
list [SCA_IActuator]
getActuators()
Gets a list of all actuators linked to this controller. (Inherited from GameTypes.SCA_IController)
integer
getExecutePriority()
Gets the execution priority of this logic brick. (Inherited from GameTypes.SCA_ILogicBrick)
string
getName()
Returns the name of the CValue. (Inherited from GameTypes.CValue)
KX_GameObject
getOwner()
Gets the game object associated with this logic brick. (Inherited from GameTypes.SCA_ILogicBrick)
SCA_ISensor
getSensor(name)
Gets the named linked sensor. (Inherited from GameTypes.SCA_IController)
list [SCA_ISensor]
getSensors()
Gets a list of all sensors attached to this controller. (Inherited from GameTypes.SCA_IController)
int
getState()
Get the controllers state bitmask, this can be used with the GameObject's state to test if the the controller is active. (Inherited from GameTypes.SCA_IController)
 
setExecutePriority(priority)
Sets the priority of this logic brick. (Inherited from GameTypes.SCA_ILogicBrick)
Instance Variables
sequence supporting index/string lookups and iteration. actuators
a list of actuators linked to this controller. (Inherited from GameTypes.SCA_IController)
int executePriority
This determines the order controllers are evaluated, and actuators are activated (lower priority is executed first). (Inherited from GameTypes.SCA_ILogicBrick)
bool invalid
Test if the object has been freed by the game engine and is no longer valid. (Inherited from GameTypes.PyObjectPlus)
int mode
the execution mode for this controller (read-only).
string name
The name of this CValue derived object (read-only). (Inherited from GameTypes.SCA_ILogicBrick)
KX_GameObject or None in exceptional cases. owner
The game object this logic brick is attached to (read-only). (Inherited from GameTypes.SCA_ILogicBrick)
string script
The value of this variable depends on the execution methid.
sequence supporting index/string lookups and iteration. sensors
a list of sensors linked to this controller (Inherited from GameTypes.SCA_IController)
int bitmask state
the controllers state bitmask. (Inherited from GameTypes.SCA_IController)
bool useHighPriority
When set the controller executes always before all other controllers that dont have this set. (Inherited from GameTypes.SCA_IController)
Method Details

activate(actuator)

 

Activates an actuator attached to this controller.

Parameters:
  • actuator (actuator or the actuator name as a string)

deactivate(actuator)

 

Deactivates an actuator attached to this controller.

Parameters:
  • actuator (actuator or the actuator name as a string)

getScript()

 

Gets the Python script body this controller executes.

Returns: string

Deprecated: Use the script attribute instead.

setScript(script_body)

 

Sets the Python script string this controller executes.

Parameters:
  • script_body (string.)

Deprecated: Use the script attribute instead.


Instance Variable Details

mode

the execution mode for this controller (read-only).
  • Script: 0, Execite the script as a python code.
  • Module: 1, Execite the script as a module and function.
Type:
int

script

The value of this variable depends on the execution methid.
  • When 'Script' execution mode is set this value contains the entire python script as a single string (not the script name as you might expect) which can be modified to run different scripts.
  • When 'Module' execution mode is set this value will contain a single line string - module name and function "module.func" or "package.modile.func" where the module names are python textblocks or external scripts. note: once this is set the script name given for warnings will remain unchanged.
Type:
string