Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
label Calculator:
$ inputNum1=renpy.input("Please enter a number")
$ inputNum2=renpy.input("Please enter the second number")
$ num1=float(inputNum1)
if except ValueError:
"Please enter a valid number"
jump Calculator
$num2=float(inputNum2)
if except ValueError:
"Please enter a valid number"
jump Calculator
However, how to detect whether the input can be converted into float? If it cannnot be converted, what code to put to detect it and loop back?
label calculator:
python:
inputNum1=renpy.input("Please enter a number")
inputNum2=renpy.input("Please enter the second number")
try:
num1=float(inputNum1)
num2=float(inputNum2)
except ValueError:
narrator("Please enter a valid number",interact=True)
renpy.jump("calculator")