Page 1 of 1

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

Posted: Sat Nov 18, 2017 3:27 am
by Soliloquy
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")]

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

Posted: Sat Nov 18, 2017 5:02 am
by mikolajspy
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

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

Posted: Sat Nov 18, 2017 5:58 am
by Imperf3kt
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

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

Posted: Sat Nov 18, 2017 2:39 pm
by Soliloquy
Thanks you guys. Having a default seems to have done the trick!