0 votes

I want to create a text adventure game where the user will interact with the world by typing commands. I want the command interface to have autocomplete so that the player knows all of their options at any given time. Currently I'm using a LineEdit node, but I'm not sure if it can meet my needs.

For example, if the player types "go to" and presses tab, they'll be presented with a list of options such as "The Library", "The Great Hall", and "Hell". Is this functionality present in any nodes within Godot? If not, how might it be possible to create this using other nodes? I'm not very familiar with control nodes, so any advice would be greatly appreciated.

in Engine by (12 points)

1 Answer

0 votes

I don't think that a LineEdit node alone will do the trick for you. And since Godot isn't a tool dedicated to creating text adventures, you probably won't find the one node that does all you have described.

Have you taken into consideration how LucasArts did it back in the days of Maniac Mansion and Zak McKracken? There, players were given several buttons with usable words to click on.

enter image description here

If that's not your style and you want to go full retro, you'd have to parse the line input as soon as the player has entered any character, check for known words inside the input and derive the player's intentions from it to finally be able to handle inputs like "use the shovel to plant the pot plant into the plant pot"... ;) Which can be done, as we all know, but it involves some hard work.

So, assuming you got the word recognition done, you could spawn buttons with labels inside them at the input cursor position. Clicking each button will result in appending their label text to the input line.

You'd have to find some way of limiting the possible auto-complete options, otherwise your list of buttons could get quite long (and gui-breaking)... There are, of course, control nodes that offer scroll functionality.

by (72 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.