[SOLVED] Character select doesn't persist through saves or rollbacks

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.
Post Reply
Message
Author
User avatar
Soliloquy
Regular
Posts: 72
Joined: Tue Aug 25, 2015 3:42 pm
Location: Mt Holly, NJ
Contact:

[SOLVED] Character select doesn't persist through saves or rollbacks

#1 Post by Soliloquy » Sat Nov 18, 2017 3:27 am

Hello folks. I'm having some trouble with my character select and was hoping that someone here could help.

Below is my select screen. [name1] and [class1] are being used in dialogue after the character is chosen, however that doesn't persist through saving and reloading, or rolling back and then forward again. When I do, the name or class is changed to <class 'ren'py.display.layout.null'>. Is there anything I'm missing, or that I can add to make the character choice stick?

Code: Select all

screen character_select:
    imagemap:
        ground "menu/character_select.png"
        hover "menu/character_select_frames.png"
    
        alpha False
        # Gemini
        hotspot(19,16,238,568) action [SetVariable("name1", "Gemini"), SetVariable("class1", "Healer"), Return("smth")]
        # Orin
        hotspot(286,15,238,568) action [SetVariable("name1", "Orin"), SetVariable("class1", "Queen"), Return("smth")]
        # Vyvian
        hotspot(548,15,240,567) action [SetVariable("name1", "Vyvian"), SetVariable("class1", "Black Widow"), Return("smth")]
Last edited by Soliloquy on Sat Nov 18, 2017 2:39 pm, edited 1 time in total.

mikolajspy
Regular
Posts: 94
Joined: Sun Jun 04, 2017 12:05 pm
Completed: Jake's Love Story
Deviantart: mikolajspy
Location: Wrocław, Poland
Contact:

Re: Character select doesn't persist through saves or rollbacks

#2 Post by mikolajspy » Sat Nov 18, 2017 5:02 am

Strange, if you defined variables they should stay with value assigned at the beginning even if they're not changed.
For example:

Code: Select all

    default name1 = John #Set to something different for debugging
    default class1 = Warrior
somewhere at the beginning, before any labels should always return to these values even if SetVariable won't work for some reason.

Did you click "Delete Persistent" or "Force Recompile" in Launcher?
Do you start new game each time? If you're loading save made before writing that part of script the variable might not be recognized.

You can also try persistent data, but then it might be the other way around - the value will stay between game sessions - https://www.renpy.org/doc/html/persiste ... stent-data

User avatar
Imperf3kt
Eileen-Class Veteran
Posts: 1039
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Character select doesn't persist through saves or rollbacks

#3 Post by Imperf3kt » Sat Nov 18, 2017 5:58 am

mikolajspy wrote:
Sat Nov 18, 2017 5:02 am
Did you click "Delete Persistent" or "Force Recompile" in Launcher?
Do you start new game each time? If you're loading save made before writing that part of script the variable might not be recognized.
Neither of these will matter if "default" was used.
As suggested, make sure you have this at the top of your script before any labels:

Code: Select all

    default name1 = John #Set to something different for debugging
    default class1 = Warrior
Image

Warning: May contain trace amounts of gratuitous plot.

User avatar
Soliloquy
Regular
Posts: 72
Joined: Tue Aug 25, 2015 3:42 pm
Location: Mt Holly, NJ
Contact:

Re: Character select doesn't persist through saves or rollbacks

#4 Post by Soliloquy » Sat Nov 18, 2017 2:39 pm

Thanks you guys. Having a default seems to have done the trick!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], troye_idk_idk