Message Sensor: subject

subject
  • gets/sets the message subject the sensor is listening for.

Type: 
  • string
Message Sensor:
  • Receives messages from a Message Actuator.
  • When the Message Sensor receives a message, one positive pulse is sent to the controller, immediately followed with one negative pulse.
Sample Code


################  Get the subject the message sensor is listening for
 
# import bge module

import bge

# get the controller
cont = bge.logic.getCurrentController()

# get the sensor attached to the controller
# my sensor is named Health

sen = cont.sensors["Health"]

# get the subject message sensor listening for
mess_subject = sen.subject
 
Sample Code


################  Set the subject the message sensor is listening for
 
# import bge module

import bge

# get the controller
cont = bge.logic.getCurrentController()

# get the sensor attached to the controller
# my sensor is named Health

sen = cont.sensors["Health"]

# Set the subject
sen.subject = "Potion"