How to Have Previous Endings and Playthroughs Affect the Ones After?

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
ArizaLuca
Veteran
Posts: 241
Joined: Tue Feb 20, 2018 12:59 pm
Completed: Through the Screen, Riddle Me This, Trust Fall, Phobias, Another Adventure
Projects: The Souls in the Seams, Fata Morgana, Minecraft: Story Mode - Behind the Scenes
Organization: Astral Autumn Games
Tumblr: astralautumngames
Deviantart: ArizaLuca
itch: astralautumngames
Contact:

How to Have Previous Endings and Playthroughs Affect the Ones After?

#1 Post by ArizaLuca »

1) In a recent game called 'belong' (https://aflutter.itch.io/belong), previous endings will affect some of the dialogue in the beginning. There is a similar game called 'Pretty Please' (https://stanza.itch.io/pretty-please) where previous endings and choices will affect the game in subsequent playthroughs. Is there any pre-existing resources that are helpful for this, and if not, how would you achieve this?

2) Is it possible to have a game erase all pre-existing endings? (Deleting the persistent from within the game.)

Thank you!

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: How to Have Previous Endings and Playthroughs Affect the Ones After?

#2 Post by kivik »

1 - that's just a case of using a persistent variable to store previous endings, and during your game code you add conditions to check the persistent variables to determine what to show.

If you have lots of endings, it's probably worth storing it as a dict in a persistent variable. Also, it's probably worth creating a function to allow shorthand checks, something that just takes a dictionary key and check whether a) it's been set and b) if it's True.

2 - Assuming you're using a dict, you can either wipe everything using del persistent.variable_name, or you can loop through the dict and set them all the False.

The advantage of setting everything to False is that you can then have 3 states for your game endings: None / unset means nobody's ever reached that ending. True means ending reached. False means ending was reached at some point, but you've since wiped it. Depends on whether the third state is important to you or not.

Bear in mind people who know what they're doing can still wipe all persistent data manually by going into the folder though, but I don't see why people would do that.

ArizaLuca
Veteran
Posts: 241
Joined: Tue Feb 20, 2018 12:59 pm
Completed: Through the Screen, Riddle Me This, Trust Fall, Phobias, Another Adventure
Projects: The Souls in the Seams, Fata Morgana, Minecraft: Story Mode - Behind the Scenes
Organization: Astral Autumn Games
Tumblr: astralautumngames
Deviantart: ArizaLuca
itch: astralautumngames
Contact:

Re: How to Have Previous Endings and Playthroughs Affect the Ones After?

#3 Post by ArizaLuca »

Apologies for the late reply! Thank you for replying. That actually helped a lot. What is a 'dict' by the way? (I'm very sorry, I am a Ren'Py noob.)

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: How to Have Previous Endings and Playthroughs Affect the Ones After?

#4 Post by kivik »

It's a Python data structure - it's called a dictionary, and it allows you to store information with paired "keys". So instead of having lots of variables with unique names, you can group related variables together, e.g.:

Code: Select all

define colors_dict = {"banana": "yellow", "carrot": "orange", "apple": "red"}
default fruit = "banana"
In that example you can refer to colors_dict[fruit] and get "yellow", and by changing the fruit variable to something else, you can retrieve the relevant colour.

In the case of your game, you can store True or False to specific keys. Here's a tutorial I found on google if you want to find out more. https://www.tutorialspoint.com/python/p ... ionary.htm

Note that's just about python dictionaries, not Renpy specifically - so you need to use python code within Renpy to use them correctly.

Post Reply

Who is online

Users browsing this forum: Google [Bot]