[SOLVED] Making multiple endings using choice menu or imagebuttons?

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
StormyThunder
Newbie
Posts: 10
Joined: Wed Aug 23, 2023 6:09 pm
Projects: Working solo on "Afterlife Feels" and its written novel.
itch: stormythunder
Discord: Huh#7134
Contact:

[SOLVED] Making multiple endings using choice menu or imagebuttons?

#1 Post by StormyThunder »

So, I'm trying to make multiple endings for my game, but what I want to do exactly kind of specific so I'll try to be as clear as I can.
I want the first play through to not show any screen for choosing an ending/route until the game is played once. When the game is started a second time, I want to be able to show a choice option between choosing the first ending/route again AND the new ending/route. And once that's played, another ending/route shows up and so on. I've been told to use persistent, but if I'm being honest, I'm still not too sure how to do that. I know how to make a choice label.
If I cannot do this, then my second option is using a more traditional way with images. However, instead of greying out an option until a certain ending is obtained, how can I show just one route and continue adding more? Is it similar to the first way I asked about?
Please ask me to clarify some things, I know this might be hard to read so I apologise in advance.
Last edited by StormyThunder on Mon Dec 11, 2023 5:07 pm, edited 1 time in total.

trailsiderice
Regular
Posts: 69
Joined: Fri Sep 29, 2023 4:02 pm
Contact:

Re: Making multiple endings using choice menu or imagebuttons?

#2 Post by trailsiderice »

Making a persistent variable is just like making any other variable, you just add "persistent." to the front of the variable.

for example, to make a variable that tracks how many times the player has played through the game, you can define a variable like this, somewhere in your code (not inside a label):

Code: Select all

default persistent.playcount = 0 # doesn't have to be playcount, can be any variable name, as long as "persistent." is in front of it
then at the end of the game, increment it like this:

Code: Select all

label end:
    $ persistent.playcount += 1
then, every time the player finishes the game, the variable will go up by one, and renpy will remember this whether the player closes the game, makes a new save, etc.

from there you can do a choice menu like this:

Code: Select all

menu:

    "Menu Option 1":
        # [default option for first playthrough]
        
    "Menu Option 2" if persistent.playcount > 1:
        # [option that appears after first playthrough]
        
    "Menu Option 3" if persistent.playcount > 2:
        # [option that appears after second playthrough]
and so on.
if you use that exact code, make sure you increment your variable before showing them the menu, or else some options might not show when you want them to. If you want to increment your variable after showing the menu, then change the ">" operators to ">="

If you wanted to do image buttons, it'd be much the same process, except you'd probably have to make a custom screen for your choice. Since it sounds like the image buttons aren't your preferred way of showing the choice, I won't go into how to do that now, but let me know if you want to know how.

User avatar
StormyThunder
Newbie
Posts: 10
Joined: Wed Aug 23, 2023 6:09 pm
Projects: Working solo on "Afterlife Feels" and its written novel.
itch: stormythunder
Discord: Huh#7134
Contact:

Re: Making multiple endings using choice menu or imagebuttons?

#3 Post by StormyThunder »

I had a little trouble because I ordered some things wrong, but it works, thank you so much!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Duhop