Okay so I'm using a text object eventually odd like to make it into a health counter. My code is sloppy though and needs refining.
Here is what I got.
import bge from bge import logic cont = logic.getCurrentController() own = cont.owner scene = logic.getCurrentScene() T = scene.objects['Text'] z = cont.sensors['z'] if z.positive: T ['x'] += 1 if T ['x'] == 0: T.text = 'failure' if T ['x'] == 1: T.text = 'success' if T ['x'] == 3: T.text = T['x']
The last line didn't work, the money says that it returns without exception set. This is just a test to find something that sort of works. But ideally I'd like the texts to simply display a variable as it changed. Z is a keyboard sensor and x is a property linked to the text. Can someone tell me how I can just get the text to display the integer property x?
Also being able to reference the lines in a text file for text would be great but if that's to much to ask then please just help me with the first one.