Message Body

I’m using a script for my mini-game which takes text, distributes it among 5 message actuator’s "body"s, and then sends the messages. The messages are then received by 5 text objects, which then run a script to set the “Text” Property the message bodies of the messages. It all works fine, but it appears as though the message bodies consist of the text surrounded by [brackets]. How do I get rid of the brackets?

you didn’t read the python docs on slices?!!!

oh well, I figure this will work

obj.Text = msgbody[1:-1]

course, it would work something like that, I dont’ have python here to try it

Nevermind, I figured it out…
I just used:

body = msg.getBodies()
text = body[0]

That fixed it. :smiley:

the reason for this is because a message sensor can recieve multiple messages on a single frame, so they are stored in a list

… yeah, and message actators can only send one message on a frame last I heard

Um, I have a question on the same sort of topic.

I’m basically trying to send a message from one object to another with a string that I want to set as the value of one of the second object’s properties.

This is what I have:

body = sensor.getBodies()
message = body[0]
#Act is a property actuator

For some reason the property gets set to :
[whatever_the_message_is not found]

Could you please help me?

do you have your python script connected to ONLY a message sensor?

Yes I only have one message sensor connected to the python controller and one property actuator connected to it.

why don’t you just set the property using python?