Collecting all scenes to get a desired ending

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
Boniae
Regular
Posts: 187
Joined: Fri Apr 10, 2009 4:10 pm
Completed: I want 2 be single and Forget-Me-Not
Projects: Cry Girlhood, Dakota Wanderers, Sagebrush
Organization: Rosewater Games
Tumblr: boniae
Location: Cleveland, OH
Contact:

Collecting all scenes to get a desired ending

#1 Post by Boniae »

I'm having a dilemma trying to figure out a way to implement this in my game, which is basically assigning a variable to a scene (which would be the love interest's route), and the player must collect all these variables in order to get a certain ending. If they're not all collected, the game will go to a default ending. If anyone can help me out with this, I'd be very, very appreciative! Thank you for reading!

User avatar
Empish
Veteran
Posts: 221
Joined: Thu Jan 14, 2016 9:52 pm
Projects: Efemural Hearts, It Ends With Graduation
itch: empish
Contact:

Re: Collecting all scenes to get a desired ending

#2 Post by Empish »

There's a few different ways you could do this, depending on how comfortable you are with Python. If you are, you could make a class called RouteVars or something, that would hold a boolean True or False for each variable that needs to be collected. If not, you can just make a list of the same things. They'd all start out as False, of course, since the player hasn't achieved any of them. And then, when they unlock or obtain a scene, at the very beginning you'd set that variable in the object or the list to be True.

Then when you choose the ending you just have to search through the object or list for anything False. If you find it, go to the default ending. If not, go to the route's ending.

User avatar
Boniae
Regular
Posts: 187
Joined: Fri Apr 10, 2009 4:10 pm
Completed: I want 2 be single and Forget-Me-Not
Projects: Cry Girlhood, Dakota Wanderers, Sagebrush
Organization: Rosewater Games
Tumblr: boniae
Location: Cleveland, OH
Contact:

Re: Collecting all scenes to get a desired ending

#3 Post by Boniae »

Hi Empish, thanks so much for the help! I'm pretty bad at python but I've been trying to look into classes, since I feel that I would have a lot of scenes to list so using a class seems more efficient, and have (sort of?) figured out a starting point using this thread on an inventory system. I'm wondering if this would be the right way to set up the class I'm looking for?

Code: Select all

python:
    class RouteVars(object):
        def __init__(self, name):
            self.name = name
And since I have three routes to go for, I could make variables for each of the characters;

Code: Select all

$ character = RouteVars('characterA')
Except now I'm totally lost on how to continue it further, or if I'm even going in the right direction, haha. @.@ If you wouldn't mind helping me a bit further I'd really appreciate it though!

User avatar
Empish
Veteran
Posts: 221
Joined: Thu Jan 14, 2016 9:52 pm
Projects: Efemural Hearts, It Ends With Graduation
itch: empish
Contact:

Re: Collecting all scenes to get a desired ending

#4 Post by Empish »

Code: Select all

init python:
    class RouteVars:
        def __init___(self, name, varlist):
            self.name = name
            self.varlist = varlist

        def isUnlocked(self):
            for var in self.varlist:
                if not var:
                    return False
            return True
You can also make it so varlist contains more complicated conditions rather than just True/False, but I figured that it'd be best to keep it simple.

You would make a RouteVars object like this:

Code: Select all

$ charAVars = RouteVars("characterA", [charA_var1, charA_var2, charA_var3])
This would make it so that when you call charAVars.isUnlocked(), you'll get True if and only if all three of those variables in the list are also True.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot], Semrush [Bot], solarisdreams