Getting an output from blender

Good morning/evening

This is question for help, I didn’t do the scripts myself

I’m trying to apply this tutorial :

In general the tutorial sounds like creating a calculator in game engine

When I press “Enter” or “Enter in numpad” the number I have entered in miles should be converted immediately to km.

Instead of converting the number, the game just show letter “E” as I press “Enter in numpad”. When pressing “Enter” nothing happens.

The scripts I used are shown in .blend file that’s attached.

I have modified and named the script with the modification Text, even though it didn’t yet

3.blend (634 KB)


To sense the enter key

Do you mean like this:


I tried putting it like this, but still doesn’t work

Maybe something like this (see above file example for download):

import bgefrom bge import logic

# Do the all keys thing
import bge

co = bge.logic.getCurrentController()
# 'Keyboard' is a keyboard sensor
sensor = co.sensors["Keyboard"]

scene = logic.getCurrentScene()
object1 = scene.objects["Text"]
object2 = scene.objects["Answer"]

def draw_text(string):
    if(string == "BACKSPACEKEY"):
        return -1
        return 1

for key,status in
    # key[0] ==, key[1] = status
    if status == bge.logic.KX_INPUT_JUST_ACTIVATED:
        string =
        if(string == "PADENTER"):
            #write your KM conversion here
            object2.text = "The answer is"
            if(draw_text(string) == -1):
                f = object1['prop'] 
                #delete the last character
                f = f[:-1]
                object1['prop'] = f
                object1.text = f
                object1['prop'] += string[3]
                object1.text = object1['prop']

sense-keys-2.blend (642 KB)

GREAT, it worked !

interesting the way your script simplified all the process in few steps

Thanks a lot =)

No worries, I’m sure I did a few things wrong, but just learning python since this week :wink:

No way! I’ve started before you by months, but with many interruptions here and there, and without connecting it with blender.

what are you learning sources?