0 votes


I found this console online to practice code.

var num1
print("Enter a number: ")

I want to store a value by keyboard.

Here I have a video but it is for python and it does not work for me in godot.

Thanks and regards

Godot version 3.2.2
in Engine by (78 points)

2 Answers

+1 vote
Best answer

The console in Godot is output only... it cannot actually interact with you. So any command line interaction will not work. Python is the closest language to GDScript but it is not actually python (which i think you know)

To take text in from the running game, I think you are looking for the LineEdit control.


I would recommend looking at that and then googling for a video tutorial that fits the style of game you are making. At a glance it looks like you would need to determine how to know when to grab the text (either a button OR a signal reacting to the ENTER key or something).

A video would be much more helpful than my attempt here :)

by (50 points)
selected by
0 votes

In godot you have something like this

if Input.is_action_pressed("button"):
       Do Something Here

In the project settings, there is an input map. You can set the button to press there and give it a name which you put in the "button" section. So if you go into the project settings, input map and create an input called First_Input and map it to the 2 key then write this code

if Input.is_action_pressed("First_Input"):
       num1 =  2

print("Enter a number: ", num1)

you will be able to change the variable with a button press.

Godot is similar to python but there are quite a few differences too. If you want to learn python I suggest downloading a standard IDE like geany for example. Hope this helps.

by (1,685 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 Frequently asked questions and 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.