Python-to-property

Ok, heres the deal. I want to have it so that in the game engine, when one property advances by 1 the phrase in the python script corresponding to that number is copied to another property. So, when the property named ‘phrase’ advances to three (for example) phrase three is copyed to the property named ‘text’.

Oh, I have very very basic knowledge of python.

Any ideas?

Hi,

You can do this with logic bricks. Set up a property sensor to detect when ‘phrase’ == 3. Then connect an AND controller to it and to a Property actuator. Set it to “Copy”, then put in “text” in the Property: field. In the Object field, put in the name of the object that has the property with phrase3 string (this can be the same object). And, of course, set the last Property to be the one with the phrase in it. Now when the sensor fires, it will copy the phrase to the “text” property. Set up other property sensors to deal with other #'s.

But if you need python, just have a script run whenever a Property Sensor set to “Changed” fires. Then in the script do this:


own = GameLogic.getCurrentController().getOwner()
if own.phrase == 1:
    own.text = "phrase 1 text"
elif own.phrase == 2:
    own.text = "phrase 2 text"
...

Tom

Cool. I wanted to use python because I need lots of phrases. Thanks!