Hi all,
I’ve taken the plunge, and started to try Python. My first small task was to get a script to read the speed of an object and output it to a property. I found and adapted one from the archives, but also thought it would be nice to have an automatic kph/mph string on the end of the speed readout. I have tried using str() but I get ‘xspeed kph’ rather than ‘123 kph’- here is what I have so far:
import GameLogic
controller = GameLogic.getCurrentController()
object = controller.owner
Xspeed, Yspeed, Zspeed = object.getLinearVelocity(False)
linSum = Xspeed
xValue = linSum
object['speed'] = xValue
kph = object['text2']
object['text'] = str("xValue" + "kph")
Where am I going wrong? I often get errors relating to str and int not mixing but I thought the str() command outputs what you send to it.
Thanks for your time!
Paul