[SOLVED] Using player input as points?
Posted: Mon Jul 19, 2021 10:08 am
I'm trying to save player input as persistent data that can later be used in an if clause. Reading through a ton of threads, I found out how to save the player input--
But when trying to use the variable as points in an if clause, it ignores it, or makes the value impossibly high.
Even if the player input is "1," the heightcheck label will still take the "elif pheight > 170" path. Additionally, when the game is restarted and ran through with persistent data, the [pheight] value is presented as "[u'1']" in the textbox rather than just the entered value. I'm not one to assume, but it seems as though player input is not saved as a pure number value and cannot be used as points in this way...?
Code: Select all
q "How tall are you in centimetres?"
python:
pheight = renpy.input("How tall are you in centimetres?", exclude='{QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm}', length=3)
pheight = pheight.strip() or __("170")
persistent.playerheight = pheight
renpy.save_persistent()
$ persistent.playerheight = [pheight]Code: Select all
label start:
"..."
call heightcheck
"..."
label heightcheck:
if pheight <= 170:
"You are [pheight]cm. You are below 170cm."
elif pheight == 170:
"You are [pheight]cm. You are 170cm."
elif pheight >= 170:
"You are [pheight]cm. You are above 170cm."
return