Handling user input via native gdscript?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GodotUser

How to handle the user input using native gdscript?

:bust_in_silhouette: Reply From: BraindeadBZH

In general the best practice to validate user input is a Regex: RegEx — Godot Engine (stable) documentation in English

Thanks for the response.

I am looking for a native gdscript solution if one exists.

GodotUser | 2019-07-10 15:41

Sorry I don’t understand, GDScript offers regex support natively.

BraindeadBZH | 2019-07-10 18:17

I’ll have to look into that, thanks.

GodotUser | 2019-07-10 23:35

:bust_in_silhouette: Reply From: GodotUser


var QTY

func _on_CalcResult_pressed():
		# get text from node as int
		QTY = int(get_node("../UI/QtyLineEdit").text)
		# Handle 0 value input (before division)
		if QTY > 0:
	# Handle any unwanted input other than an integer greater than 0
				print("Please enter a valid int above 0 for Quantity")
				print(" ")