2004-05-30 11:09:46 +00:00
|
|
|
# $Id$
|
2004-05-24 07:49:50 +00:00
|
|
|
# Documentation for SCA_PythonController
|
2004-06-02 12:43:27 +00:00
|
|
|
from SCA_IController import *
|
2004-05-24 07:49:50 +00:00
|
|
|
|
2004-06-02 12:43:27 +00:00
|
|
|
class SCA_PythonController(SCA_IController):
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
A Python controller uses a Python script to activate it's actuators,
|
|
|
|
based on it's sensors.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def getSensors():
|
|
|
|
"""
|
|
|
|
Gets a list of all sensors attached to this controller.
|
|
|
|
|
2004-06-02 12:43:27 +00:00
|
|
|
@rtype: list [L{SCA_ISensor}]
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
def getSensor(name):
|
|
|
|
"""
|
|
|
|
Gets the named linked sensor.
|
|
|
|
|
|
|
|
@type name: string
|
2004-06-02 12:43:27 +00:00
|
|
|
@rtype: L{SCA_ISensor}
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
def getActuators():
|
|
|
|
"""
|
|
|
|
Gets a list of all actuators linked to this controller.
|
|
|
|
|
2004-06-02 12:43:27 +00:00
|
|
|
@rtype: list [L{SCA_IActuator}]
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
def getActuator(name):
|
|
|
|
"""
|
|
|
|
Gets the named linked actuator.
|
|
|
|
|
|
|
|
@type name: string
|
2004-06-02 12:43:27 +00:00
|
|
|
@rtype: L{SCA_IActuator}
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
def getScript():
|
|
|
|
"""
|
|
|
|
Gets the Python script this controller executes.
|
|
|
|
|
|
|
|
@rtype: string
|
|
|
|
"""
|
|
|
|
def setScript(script):
|
|
|
|
"""
|
|
|
|
Sets the Python script this controller executes.
|
|
|
|
|
|
|
|
@type script: string.
|
|
|
|
"""
|
2008-06-29 21:52:23 +00:00
|
|
|
def getState():
|
|
|
|
"""
|
|
|
|
Get the controllers state bitmask, this can be used with the GameObject's state to test if the the controller is active.
|
|
|
|
This for instance will always be true however you could compare with a previous state to see when the state was activated.
|
|
|
|
GameLogic.getCurrentController().getState() & GameLogic.getCurrentController().getOwner().getState()
|
|
|
|
|
|
|
|
@rtype: int
|
|
|
|
"""
|
2004-05-24 07:49:50 +00:00
|
|
|
|