| Methods: |
| getConeHeight |
getConeTarget |
| getConeOrigin |
----------
|
|
Inherited
Methods: |
| getExecutePriority |
isA |
| getFrequency |
isPositive |
| getHitObject |
isTriggered |
| getHitObjectList |
reset |
| getInvert |
setExecutePriority |
| getLevel |
setFrequency |
| getName |
setInvert |
| getProperty |
setLevel |
| getOwner |
setProperty |
| getUseNegPulseMode |
setUseNegPulseMode |
| getUsePosPulseMode |
setUsePosPulseMode |
|
|
getConeHeight
getConeHeight()
Returns the distance the radar is checking.
Return type: float
Note:
This is the distance from the object's
center. Not the object's sides.
Sample
Code
# get the controller.
controller = GameLogic.getCurrentController()
# get the Radar sensor named GuardDuty
radar = controller.getSensor("GuardDuty")
# get distance guard is checking
dist = radar.getConeHeight()
getConeOrigin
getConeOrigin()
Returns the origin of radar with which to test.
Return type: list [ x, y, z]
Sample
Code
# get the controller.
controller = GameLogic.getCurrentController()
# get the Radar sensor named GuardDuty
radar = controller.getSensor("GuardDuty")
# get radar cone origin
coneOrigin = radar.getConeOrigin()
getConeTarget
getConeTarget()
Returns the center of the bottom face of the radar cone.
Return type: list[ x, y, z]
Sample
Code
# get the controller.
controller = GameLogic.getCurrentController()
# get the Radar sensor named GuardDuty
radar = controller.getSensor("GuardDuty")
# get cone target
coneTarget = radar.getConeTarget()
getHitObject
getHitObject()
Returns the last object hit by the radar sensor.
Return type: KX_GameObject
Sample
Code
# get the controller
controller = GameLogic.getCurrentController()
# get the sensor named Guard
sen = controller.getSensor("Guard")
# get last object hit by radar sensor
obj = sen.getHitObject()
# get the name
name = obj.name
getHitObjectList
getHitObjectList()
Returns a list of the objects hit by the radar sensor in the last frame.
Return type: List [ KX_GameObject ]
Sample
Code
# get the controller
controller = GameLogic.getCurrentController()
# get the sensor named Guard
sen = controller.getSensor("Guard")
# get a list of the objects hit in the last frame
objList = sen.getHitObjectList()
# get the name of first object in the list
name = objList[0].name
getProperty
getProperty()
Returns the name of the property that the radar sensor looks for.
Return type: string
Sample
Code
# get the controller
controller = GameLogic.getCurrentController()
# get the sensor named Guard
sen = controller.getSensor("Guard")
# get name of material sensor looks for
name = sen.getProperty()
setProperty
setProperty(name)
Sets the name of the property that the radar sensor looks for.
name:
Type:
string
Note:
For
setProperty(name) to change the property that triggers the radar
sensor,
a property with the name you're changing to must already be listed
under Add Property of the object attached to the radar sensor.
If it isn't, the property won't be changed.
Sample
Code
# get the controller
controller = GameLogic.getCurrentController()
# get the sensor named Guard
sen = controller.getSensor("Guard")
# set name of material sensor looks for
sen.setProperty("BlueTeam")
getFrequency
getFrequency()
Returns the delay between repeated pulses.
Return Type: Integer
0 = no delay.
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get sensor named sensor
sen = controller.getSensor("sensor")
# get sensor Frequency
pulseFreq = sen.getFrequency()
getInvert
getInvert()
Returns if sensor is set to activate on negative events.
Return Type: Bool
True = sensor
activated on negative events
False = sensor activated on positive events
Note:
It is supposed to return a bool.
1 = True
0 = False
It doesn't. Instead it returns
1 = True
2 = False
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get sensor named sensor
sen = controller.getSensor("sensor")
# trigger on negative pulse?
trigger = sen.getInvert()
getLevel
getLevel()
The Level button is a part of the State System.
Returns whether or not the level (Lvl) button is active.
Level button activated:
Deactivated mouse
sensor is reactivated:
Checks to see if a
mouse button is being pressed.
If it is, it sends a pulse to the controller.
Level button not activated:
Deactivated mouse
sensor is reactivated:
Doesn't check to see
if a mouse button is being pressed.
Doesn't send pulse to the controller.
Return Type: Bool
1 = True = Level
button active.
2 = False = Level button inactive.
Note:
Only works reliably when the sensor is connected to a
single state.
Note:
It is supposed to return a bool.
1 = True
0 = False
It doesn't. Instead it returns
1 = True
2 = False
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get sensor named sensor
sen = controller.getSensor("sensor")
# send pulse when activated by State System?
sendPulse = sen.getLevel()
getUseNegPulseMode
getUseNegPulseMode()
Returns if sensor is set to use negative pulse.
Return Type: Bool
1 = True = Use
negative pulse
2 = False = Don't use negative pulse
Note:
It is supposed to return a bool.
1 = True
0 = False
It doesn't. Instead it returns
1 = True
2 = False
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get sensor named sensor
sen = controller.getSensor("sensor")
# trigger on negative pulse?
trigger = sen.getUseNegPulseMode()
getUsePosPulseMode
setBlendtime(blendtime)
Returns if sensor is set to use positive pulse.
Return Type: Bool
1 = True = Use
positive pulse
2 = False = Don't use positive pulse
Note:
It is supposed to return a bool.
1 = True
0 = False
It doesn't. Instead it returns
1 = True
2 = False
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get sensor named sensor
sen = controller.getSensor("sensor")
# trigger on positive pulse?
trigger = sen.getUsePosPulseMode()
isPositive
isPositive()
Returns True when sensor is activated. False when it is
deactivated.
Return Type: Bool
1 = True = sensor
activated
0 = False = sensor deactivated
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get sensor named sensor
sen = controller.getSensor("sensor")
# sensor being activated? Deactivated?
activated = sen.isPositive()
isTriggered
isTriggered()
Returns if sensor has triggered the controller
Return Type: Bool
1 = True = sensor
triggered controller
0 = False = sensor hasn't triggered controller
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get sensor named sensor
sen = controller.getSensor("sensor")
# sensor triggered controller?
trigger = sen.isTriggered()
reset
reset()
Resets the sensor to it's initial state. (ie. just activated)
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get sensor named sensor
sen = controller.getSensor("sensor")
# reset the sensor
sen.reset()
setFrequency
setFrequency(freq)
Sets the delay between repeated pulses.
freq:
Type is integer.
0 = no delay.
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get sensor named sensor
sen = controller.getSensor("sensor")
# set Frequency to no delay
sen.setFrequency(0)
setInvert
setInvert(inv)
Sets if the sensor is to activate on negative events.
inv:
Type: Bool.
1 = True
= activate on negative events
0 = False = activate on positive events
Note:
True, False and 1, 0 work as expected
But
setInvert(2)
sets it to True
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get sensor named sensor
sen = controller.getSensor("sensor")
# set to activate on negative events
sen.setInvert(True)
setLevel
setLevel(activate)
The Level button is a part of the State System.
Sets whether or not the level (Lvl) button is active.
Level button activated:
Deactivated mouse
sensor is reactivated:
Checks to see if a
mouse button is being pressed.
If it is, it sends a pulse to the controller.
Level button not activated:
Deactivated mouse
sensor is reactivated:
Doesn't check to see
if a mouse button is being pressed.
Doesn't send pulse to the controller.
activate:
Type: Bool
1 or True = Level button active.
0 or False = Level button inactive.
Note:
Only works reliably when the sensor is connected to a
single state.
Note:
True, False and 1, 0 work as expected
But
setLevel(2)
2 sets it to True
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get sensor named sensor
sen = controller.getSensor("sensor")
# set level detector to True
sen.setLevel(True)
setUseNegPulseMode
setUseNegPulseMode(pulse)
Sets the sensor to use negative pulse mode.
pulse:
Type
= Bool.
1 = True = Use
negative pulse mode
0 = False = Use positive pulse mode
Note:
True, False and 1, 0 work as expected
But
getUseNegPulseMode()
2 = False
setUseNegPulseMode(2)
2 sets it to True
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get sensor named MouseOver
sen = controller.getSensor("sensor")
# set to use on negative pulse
sen.setUseNegPulseMode(True)
setUsePosPulseMode
setUsePosPulseMode(pulse)
Sets the sensor to use positive pulse mode.
pulse:
Type
= Bool.
1 = True = Use
positive pulse mode
0 = False = Use negative pulse mode
Note:
True, False and 1, 0 work as expected
But
getUsePosPulseMode()
2 = False
setUsePosPulseMode(2)
2 sets it to True
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get sensor named MouseOver
sen = controller.getSensor("sensor")
# set to use on positive pulse
sen.setUsePosPulseMode(True)
getExecutePriority
getExecutePriority()
Gets the execute priority of the logic brick
Return Type: integer
Doesn't
work:
Crashes Blender
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get the actuator named act
act = controller.getActuator("act")
# get brick priority
priority = act.getExecutePriority()
getOwner
getOwner()
Gets the game object that owns the logic brick.
Return Type: KX_GameObject
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get the actuator named act
act = controller.getActuator("act")
# get brick owner
owner = act.getOwner()
setExecutePriority
setExecutePriority(priority)
Sets the execution priority of the logic brick.
priority:
Type: integer
0 is first
1 is second
etc.
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get the actuator named act
act = controller.getActuator("act")
# set brick priority to be first
act.setExecutePriority(0)
isA
isA(Type)
Checks the Object type.
(KX_GameObject,
SCA_ILogicBrick, KX_Scene, etc.)
Type: String
Return Type: Bool
1 = True
0 = False
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get the object controller attached to
owner = controller.getOwner()
# is owner a GameObject?
gameObject = owner.isA("KX_GameObject")
getName
getName()
Returns the name of actuator
Return Type: string
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get a list of the attached actuators
actList = controller.getActuators()
# loop through the list of actuators
for act in actList:
# look for an
actuator named "RocketMotion"
if act.getName() ==
"RocketMotion":
# use it
GameLogic.addActiveActuator(act,
True)
# Done.
Break out of loop
break
|