Python code that sets message body

I have Bender version 2.65 and I tried the code: “messageactuator.setbody”, which didn’t work. Is there a different code I am supposed to use for the version of blender that I have?

you can send messages from python directly, without the logic bricks. Look here

You could also directly alter Python variables through Python, eliminating the need to use messages at all (unless you need to ‘communicate’ with a lot of objects at the same time. If this is the case, maybe message sending would be more efficient, though I’m not 100% sure on that).

Would I use the capital ‘M’ like it is used here?
sendMessage(subject, body="", to="")

So for example would I write

sendMessage(text, body=“String”, to=“bpy.data.objects[“target object”]) ?

I’m not quite sure how I should reference the target object. And what if, for example, I want to reference an object from a different scene.

Thanks by the way, your comments were really helpful. I still have trouble understanding the API manuals however, otherwise I would be utilizing it a lot more often.

Yeah, the API isn’t great, but occasionally (if it hasn’t changed from 2.4) you can look at tutorialsforblender3d.com as an alternative API
For sendMessage it says:

sendMessage(subject, body, to)

Sends a message.

subject: The subject of the messageType: string

body: The body of the message (optional)Type: string

to: The name of the object to send the message to (optional)Type: string

Sample Code

# get controller

controller = GameLogic.getCurrentController()

# get game object controller is attached to

obj = controller.owner

# send message to object nameed OBHUD

obj.sendMessage(“Health”, “-10”, “OBHUD”)

Never use bpy!

The official BGE API is here: http://www.blender.org/documentation/blender_python_api_2_65_9/bge.logic.html

Even if you can send to one specific object I recommend not to do so. This creates a dependency towards the name of the existing object.

Better send a message with a specific subject. This makes the sender not care how many receiver exist.
The receiver filter for subject. So they do noz care who or how many sender submitted the message.