Game Logic: sendMessage

sendMessage(subject)
  • Sends a message to a sensor

subject:

  • The subject of the message
  • Type:  String
sendMessage(subject, body)
  • Sends a message to a sensor

subject:

  • The subject of the message
  • Type:  String
body:
  • The body of the message.
  • Type:  String
sendMessage(subject, body, to)
  • Sends a message to a sensor

subject:

  • The subject of the message
  • Type:  String
body:
  • The body of the message.
  • Type:  String
to:
  • The name of the object to send the message to.
  • Type:  String
sendMessage(subject, body, to, from)
  • Sends a message to a sensor

subject:

  • The subject of the message
  • Type:  String
body:
  • The body of the message.
  • Type:  String
to:
  • The name of the object to send the message to.
  • Type:  String
from:
  • The name of the object that the message is coming from.
  • Type:  String
Sample Code

################## Send a message
   

# import bge
import bge

# message subject
subject = "Locked Chest"

# Send a message
bge.logic.sendMessage(subject)

Sample Code

################## Send a message
  

# import bge
import bge

# message subject
subject = "Locked Chest"

# message body
body = "Lock can't be picked."

# Send a message
bge.logic.sendMessage(subject, body)

Sample Code

################## Send a message

# import bge
import bge

# message subject
subject = "Locked Chest"

# message body
body = "Lock can't be picked."

# send message to
to = "Hero"

# Send a message
bge.logic.sendMessage(subject, body, to)

Sample Code

################## Send a message
   

# import bge
import bge

# message subject
subject = "Locked Chest"

# message body
body = "Lock can't be picked."

# send message to
to = "Hero"

# send message from
from = "Treasure Chest"

# Send a message
bge.logic.sendMessage(subject, body, to, from)