Standalone Player Comparing Strings

I’ve got a very simple scene where the text typed on the keyboard gets applied to a text-object.
When return is pressed this script runs:

import bge

cont=bge.logic.getCurrentController()
own=cont.owner

if(own['Text']=="quit"):
    bge.logic.endGame()
else:
    own['Text']=""

It checks if the input text equals “quit” and if so quits the game.
This also works if I run it directly in blender, but however when I try this with the stanalone player,
it won’t do anything but setting the “Text”-property back to an empty string.
If I add print(own[‘Text’]) it also prints the right text in the console.

It gets even weirder when I try to print something like: own[‘Text’] + “abc”
Running in blender it prints this:quitabc

in the standalone player this:abct
abc

Does anybody know why it does this??

It seems that the logged input includes the RETURN character in the blenderplayer, but not in the embedded player. The two systems are not exact duplicates of one another, so I would not be surprised that this happens, but a bug report would be warranted.

To solve the problem, compare against the stripped value of the text field:


stripped = own['Text'].strip()

if stripped == "quit":
    pass

Another way is to remove the last character of the string before checking it.

I would be tempted to do a find:


if own['Text'].find('quit') != -1:
    quit()