Sending properties

I can get one game object to read another objects properties using Copy Property, but I can’t get an object to say “OI, Object Cube10! Your property ‘Text’ is now ‘Magenta!’!”.

Send Message allows you to put a property into the content of the message, but I can’t work out how to get the object to receive the content of the message.

I can send out
Send Message
To: Cube10
Subject: Text
Body: Magenta

But I don’t know how to get Cube10’s logic blocks read the Body.

How is this done? Does it need Python?

That is true. It is a funny point of the Logic bricks that you can put in a value but you can’t do anything with it ;).

There is a way around it. Look at S2A. It provides a function to let you put the message body into a property:

Message sensor (true pulse!) -> Python Module controller S2A.firstBodyToValue -> Property Actuator (setup prop: leave value: empty)

You find a description in Post 5.

[edit]
alternative way:
when the property changes send a messages as you already do, but no body required. The message itself is the signal for the other object, to copy the property value from the first object.

message sensor -> and -> property actuator (copy mode)
[/edit]
I hope it helps

Thank you - that looks very helpful, and thanks for your quick reply.

Quite a large chunk to learn.

But I think I can manage.

The alternative way isn’t so useful for me— There are a series of objects created through Edit Object: Add Object that should give an info string to a speech-bubble object when rolled over.

It’s for an Objectives menu for this project - http://yogyog.org/wiki/doku.php?id=franz_kafka_s_metamorphosis - looking at what you’ve been working on I think this may interest you.

You need a script… I have one if you need…

Thanks again, Monster - your script works fantastically, but to be honest I’d quite like to just know how to access other obect’s variables through python.

You can use

cont=GameLogic.getCurrentController()
own=cont.owner

Can you do something similar to access another object?

as long you have a reference to the game object you can access all the game objects data.

cont.owner is reference
sensor.owner and
actuator.owner another one
sensor.hitObject is a reference :wink:

or you can parse through all objects of a scene:


scene = GameLogic.getCurrentScene()
allObjects = scene.objects

#all objects with the same name:
myObjects = [obj for obj in allObjects if obj.name == "myObject"]

Be carefull with scene.objects[“myObject”] it returns one object even if there are more with that name. This happens when working with addObject or groups.

This functions can be found in the API