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.
[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.
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.
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
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.