How do I make Sirl's using only text runing in BGE, so a chatbot in-game?

here is what I have from a python video

import random

greetings = [‘hola’,‘hello’,‘hi’,‘Hi’,‘hey!’,‘hey’]
random_greeting = random.choice(greetings)

question = [‘How are you?’,‘How are you doing?’]
responses = [‘Okay’,“I’m fine”]
random_response = random.choice (responses)

####raw_input was changed to just input in the new python I found-out
while True:
userInput = input(’>>>’)
if userInput in greetings:
elif userInput in question:
print(“I did not understand what you said”)

Rather then printing in a command console I’d like to change Text objects
so I wanted to replace “print” with

import bge

cont = bge.logic.getCurrentController()
own = cont.owner
#I would replace print with own.text =
own.text =“The new text I want”

I’m new to programing in python, my game runs but doesn’t respond. Is it running too many times / to fast even if I lowered the games Frame rate as low as it will go?
Please help me out.
I’m trying to make a text only based adventurer game like the old 90’s pc games for the BGMC going on right now.

> text
> bge
choose one

Both, blender game engine has text objects,
as I said I want to replace “print” with this down below.

cont = bge.logic.getCurrentController()
own = cont.owner
own.text =“The new text I want”

so I don’t need a command console
rather the game object Text would change it’s Str Variable

When posting code please use code tags. Otherwose it is nearly unreadable.

This link might help you:
Can’t make BGE to accept the string “
” string in exptression to activate an actuator

Yeah, don’t be absurd. The BGE, and any other game engine that supports text and input checking, can do text-based games just fine.

@Joshua - Text adventure games are pretty complex, with a lot of emphasis on parsing. I’m not sure if you can pull it off for a short competition as it stands (unless it’s months long or something). You might do better with a simpler project. As for solving your actual issue, you’re using a while loop, which doesn’t quit unless the condition evaluates to false. Being that you entered “while True:”, it just continues indefinitely, and the game engine can never continue.

EDIT: Oh, and if you try to do text adventure games with the BGE, you’d probably need to recreate a console (just displaying info and writing text) in the engine, as unless there’s a way to launch the game without a display window, you’d have an empty window and have to do stuff in the console, which seems a bit awkward.

It was the short answer to: There is no way you’ll ever make a good text based game in BGE using text objects and game properties, any other engine would be better, actually you may be better just using the terminal if you have to use the BGE.

I know, we are on the BGE forums and saying BGE is crap at something may not be correct, but this:

Not to say that BGE and any other 3D game engine is too overbloated for a text-based game, heck your text-based game that barely uses any graphics will not even run on android.

for part in string–> add plane that is uv text

works pretty well,

have you seen the Sprite example provided by SdfGeoff?
one could bind a dictionary value from a letter to a color

{ F:.555 D:.556 }


and what is wrong with bge integrated text ?

It needs proper ‘center’ and ‘Left’ Justify but all else works quite well.

That issue wouldn’t really be a big deal in a text-only game, though that is a strange bug. I don’t think stating the problems with the BGE is “wrong”, though.

You are correct, though, that a full 3D engine is overkill for a text-based game; any basic programming language can do text in a terminal, so unless you need some kind of 3D rendering, it’s not really necessary.

You do not need a game engine on a “text only based adventurer game”.

Such an application (yes a game is an application to) does not need a game engine framework:

  • Render engine: plain text console - comes with the OS
  • User input: plain text console - comes with OS
  • Physics: not needed
  • Networking: if needed at all - nearly all programming languages have tcp/udp libraries somewhere
  • Sound: not needed (it is text based)

So my advice: A pure text based game can be created with pure python and a console window.

But this might be a misunderstanding:

@Joshua Jay: do you mean that the user-interaction is based on entering text, while the game is a 3D-Rendered game (like Leisure Suit Larry I or Space Quest I)?

Not in a text-only game, but a pretty annoying bug in a text-based game where you have objects (sprites/images/widgets) behind the text.

I never played them, I was wanting something like what was in the Tom Hanks movie “Zoltar Speaks” the kid was playing before school where he typed in what his player would do, like attack the wizard; but using python and BGE make it more advanced.