fix: allows for bare decimals (no leading 0) to be properly interpreted; also adds in additional validation for 'wait' command

This commit is contained in:
Duncan Brown
2022-04-15 15:19:55 -04:00
committed by Julian Murgia
parent 7050a8a2fb
commit 768f65d929
2 changed files with 19 additions and 1 deletions

View File

@@ -20,6 +20,24 @@ func configure() -> ESCCommandArgumentDescriptor:
)
# Validate whether the given arguments match the command descriptor
func validate(arguments: Array):
if not .validate(arguments):
return false
# We can't wait for 0 or fewer seconds, now, can we?
if arguments[0] <= 0.0:
escoria.logger.report_errors(
"wait: argument invalid",
[
"%ss is an invalid amount of time to wait." % arguments[0],
"Time to wait must be positive."
]
)
return false
return true
# Run the command
func run(command_params: Array) -> int:
yield(escoria.get_tree().create_timer(float(command_params[0])), "timeout")

View File

@@ -43,7 +43,7 @@ func get_typed_value(value: String, type_hint = []):
var regex_bool = RegEx.new()
regex_bool.compile("^true|false$")
var regex_float = RegEx.new()
regex_float.compile("^-?[0-9]+\\.[0-9]+$")
regex_float.compile("^-?[0-9]*\\.[0-9]+$")
var regex_int = RegEx.new()
regex_int.compile("^-?[0-9]+$")