Jump to content

User input/Text: Difference between revisions

GDScript
mNo edit summary
(GDScript)
Line 1,106:
s = input["Enter a string: "]
i = parseInt[input["Enter an integer: "]]
</syntaxhighlight>
 
=={{header|GDScript}}==
{{works with|Godot|4.0}}
 
Run with <code>godot --headless --script <file></code>
 
<syntaxhighlight lang="gdscript">
extends MainLoop
 
func _process(_delta: float) -> bool:
printraw("Input a string: ")
var read_line := OS.read_string_from_stdin() # Mote that this retains the newline.
 
printraw("Input an integer: ")
var read_integer := int(OS.read_string_from_stdin())
 
print("read_line = %s" % read_line.trim_suffix("\n"))
print("read_integer = %d" % read_integer)
 
return true # Exit instead of looping
</syntaxhighlight>
 
89

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.