Variables and Replay

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
Uy27
Regular
Posts: 29
Joined: Wed Apr 04, 2018 2:07 am
Contact:

Variables and Replay

#1 Post by Uy27 »

Hello

I am trying to add a scene gallery to my game. Calling the replay seems simple enough but how do you make replay remember some variables?
For example, in my game the player writes their own name (povname = playername) so in a replay every time the player talks it gives the error (povname not defined) and the same with any other variables such as "if variable b is true:" stuff.

How to be able to make scene replays with those variables not removed?

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Variables and Replay

#2 Post by rayminator »

can you post your code that you are using?

are you using:
textbotton?
hotspots?
imagebuttons?

here are some examples textbutton you can do the same for other as well

SetField:

Code: Select all

textbutton _("Cousin Hearts") action [ ShowMenu("test"), SetField(cousin, "lim", cousin.lim+50) ]
SetVariable:

Code: Select all

textbutton _("Rat") action [ ShowMenu("test"), SetVariable("rat_mouse.have", True) ]

Uy27
Regular
Posts: 29
Joined: Wed Apr 04, 2018 2:07 am
Contact:

Re: Variables and Replay

#3 Post by Uy27 »

rayminator wrote: Tue Oct 22, 2019 3:42 pm can you post your code that you are using?

are you using:
textbotton?
hotspots?
imagebuttons?

here are some examples textbutton you can do the same for other as well

SetField:

Code: Select all

textbutton _("Cousin Hearts") action [ ShowMenu("test"), SetField(cousin, "lim", cousin.lim+50) ]
SetVariable:

Code: Select all

textbutton _("Rat") action [ ShowMenu("test"), SetVariable("rat_mouse.have", True) ]
The code right now is merely for testing but look like this

Code: Select all

    textbutton "The meaning of life":

        action Replay("gracieMovie1")
        xalign 0.5
        yalign 0.95
Not sure how to setfield with that and if setfield works with replays (documentations regarding replays don't tell anything about that)

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Variables and Replay

#4 Post by rayminator »

try this if this you want i have tried it and works for me but i did use the replay cause i don't have it so hope it works for you that you want it too

Edit: it only work inside of the game

Code: Select all

textbutton _("testing") action [ Jump("test"), povname.strip() ]

Code: Select all

textbutton "The meaning of life":

        action [ Replay("gracieMovie1"), povname.strip() ]
        xalign 0.5
        yalign 0.95

Uy27
Regular
Posts: 29
Joined: Wed Apr 04, 2018 2:07 am
Contact:

Re: Variables and Replay

#5 Post by Uy27 »

rayminator wrote: Tue Oct 22, 2019 9:40 pm try this if this you want i have tried it and works for me but i did use the replay cause i don't have it so hope it works for you that you want it too

Edit: it only work inside of the game

Code: Select all

textbutton _("testing") action [ Jump("test"), povname.strip() ]

Code: Select all

textbutton "The meaning of life":

        action [ Replay("gracieMovie1"), povname.strip() ]
        xalign 0.5
        yalign 0.95
EDIT*

It worked! Thanks for the help.

Code: Select all

    textbutton "The meaning of life":
        action Replay("gracieMovie1", scope={ "povname" : "Slow" })
        xalign 0.5
        yalign 0.95

Post Reply

Who is online

Users browsing this forum: Milkymalk