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.
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--
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]
But when trying to use the variable as points in an if clause, it ignores it, or makes the value impossibly high.
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
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...?
Last edited by ZeAwesomeHobo on Mon Jul 19, 2021 1:24 pm, edited 1 time in total.
Main Website
Includes information about and links to many of my current and past projects.
Major Game Projects
[Nightshade] Eldritch Academy, Eldritch University, Blooming Nightshade, Flowering Nightshade, Life as Designed
[Team Despair] Corpse Party D2 series
python:
pheight = renpy.input("How tall are you in centimetres?", exclude='{QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm}', length=3)
pheight = pheight.strip() or __("80")
pheight = int(pheight) ##Adding this line fixed the issues.
persistent.playerheight = pheight
renpy.save_persistent()