Renpy replay not using variables

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
matrixglasses69
Newbie
Posts: 1
Joined: Mon Mar 16, 2020 9:21 am
Contact:

Renpy replay not using variables

#1 Post by matrixglasses69 »

hi everyone!

is there a way to keep variables during renpy replay? replaying a scene with multiple paths is causing us issues. all the variables seem to reset in replay

and another question. Is there a command for "if in replay: jump newlabel" and such?? Basiclly "if in replay: do this or that"

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Renpy replay not using variables

#2 Post by RicharDann »

This is the first time I actually try out this code so this may not be the perfect solution, but according to the documentation here, you have to pass each variable and value pair as a dictionary, using the 'scope' keyword argument, either with the Replay() action or with renpy.call_replay() function, so Ren'Py can set the values before launching the replay.

For the second question, there's a built in _in_replay variable that can be used to check if you're in replay mode or not.

A quick example:

Code: Select all

default a_number = 0
default a_string = ""

screen replay_gallery():
    
    textbutton _("Scene 01") action Replay("scene_01", scope={"a_number":100, "a_string":"Hello"})

Code: Select all

    
label scene_01:

    if _in_replay:
        "This scene is being replayed."
    
    "Let's test an int variable: [a_number]"
    
    "Let's test with a string: [a_string]"
    
    $ renpy.end_replay()    
I don't have time to do some more testing but hopefully this is a start.
The most important step is always the next one.

Post Reply

Who is online

Users browsing this forum: Andredron, Google [Bot], Shie