Class SCA_PythonController (2.48)


Methods
getActuator getSensors
getActuators getState
getScript setScript
getSensor ----------
 
Variables
---------- ----------
 
Constants
---------- ----------

Inherited Methods:  Class SCA_ILogicBrick
getExecutePriority setExecutePriority
getOwner ----------

Inherited Methods:  Class PyObjectPlus
isA ----------

Inherited Methods:  Class Value
getName ----------



Methods



getActuator

getActuator(name)

Returns the named actuator if it is linked to the controller.

Return type:  SCA_IActuator

name:
Type:  string

Sample Code

# get the controller
controller = GameLogic.getCurrentController()

# get the actuator named StartGame attached to the controller
act = controller.getActuator("StartGame")

getActuators

getActuators()

Returns a list of the actuators linked to the controller.

Return type:  list [SCA_IActuator]

Sample Code

# get the controller
controller = GameLogic.getCurrentController()

# get a list of the actuators attached to the controller
actList = controller.getActuators()

getScript

getScript()

Returns the python script attached to the controller.  (All of it.  Every line.)

Return type:  string

Sample Code

# get the controller
controller = GameLogic.getCurrentController()

# get the python script the controller uses
scriptComplete = controller.getScript()

getSensor

getSensor(name)

Returns the named sensor if it is linked to the controller.

Return type:  SCA_ISensor

name:
Type:  string

Sample Code

# get the controller
controller = GameLogic.getCurrentController()

# get the sensor named sensor attached to the controller
sen = controller.getSensor("sensor")

getSensors

getSensors()

Returns a list of the sensors linked to the controller.

Return type:  list [SCA_ISensor]

Sample Code

# get the controller
controller = GameLogic.getCurrentController()

# get a list of the sensors attached to the controller
senList = controller.getSensors()

getState

getState()

Returns the State Mask group the controller belongs to.

Return type:   integer

1 = State Mask group 1 active
2 = State Mask group 2 active
3 = State Mask groups 2 and 1active
4 = State Mask group 3 active
5 = State Mask groups 3 and 1 active
6 = State Mask groups  3 and 2 active
7 = State Mask groups 3 and 2 and 1 active
8 = State Mask group 4 active
etc
16 = layer 5
etc
32 = layer 6
etc

Sample Code

# get the controller
controller = GameLogic.getCurrentController()

# get the state mask group number
group = controller.getState()

setScript

setScript(script)

Sets the script to be attached to the controller.

script:
Type:  string

Note:
script isn't the name of the python script.  It is the complete script.  Every line.

One way: script all on one line

Sample Code 

# get the controller
controller = GameLogic.getCurrentController()

# set the script to show mouse pointer
controller.setScript("import Rasterizer\nRasterizer.showMouse(True)")



Blender 3D
Game Engine