Limiting amount of choices from menu that can be selected

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
Izzayuh
Newbie
Posts: 15
Joined: Sat Mar 19, 2016 12:06 am
Projects: Masked, Lovetale
Tumblr: izzycle
Deviantart: izzysdoodles
Contact:

Limiting amount of choices from menu that can be selected

#1 Post by Izzayuh »

Still getting used to coding, so wasn't too sure how to get what I wanted for the VN I'm making.
Basically, at the beginning you're taken on a university tour, and an in-game menu will come up from which you can choose where you want to be taken, or if you want to just go straight to the dorms (which progresses the story, but means you don't meet the dateable characters)
Each choice leads to a semi-long scene, so I wouldn't want the player to choose more than about three before they return to the dorms, so is there any way that I can put this limit on?
I also wanted the menu to remember the places that the player has already toured, so that they can't repeat scenes.
Does anyone know how I could put these in?

User avatar
theCodeCat
Regular
Posts: 62
Joined: Sun Sep 06, 2015 8:40 pm
Projects: Lucid9, Mystic Destinies: Serendipity of Aeons
Skype: theCodeCat
Contact:

Re: Limiting amount of choices from menu that can be selecte

#2 Post by theCodeCat »

You could do something like:

Code: Select all

label start:
    "content leading into choice"
    python:
        # 0 = Not toured, 1 = Toured
        touredSpotA = 0
        touredSpotB = 0
        touredSpotC = 0
        touredSpotD = 0

label tourChoice:
    # Count how many locations have been visited and check if that number is above some threshold
    if touredSpotA + touredSpotB + touredSpotC + touredSpotD >= 3:
        # Force player to go to dorm
        jump dorm
    menu:
        "Where would you like to go next?"
        "Location A" if touredSpotA == 0:
            $ touredSpotA = 1
            jump spotATour
        "Location B" if touredSpotB == 0:
            $ touredSpotB = 1
            jump spotBTour
        "Location C" if touredSpotC == 0:
            $ touredSpotC = 1
            jump spotCTour
        "Location D" if touredSpotD == 0:
            $ touredSpotD = 1
            jump spotDTour
        "Dorm":
            jump dorm

label spotATour:
    "Some content"
    jump tourChoice

label spotBTour:
    "Some content"
    jump tourChoice

label spotCTour:
    "Some content"
    jump tourChoice

label spotDTour:
    "Some content"
    jump tourChoice

label dorm:
    "game continues here"

but name the labels and variables something more descriptive.

User avatar
Izzayuh
Newbie
Posts: 15
Joined: Sat Mar 19, 2016 12:06 am
Projects: Masked, Lovetale
Tumblr: izzycle
Deviantart: izzysdoodles
Contact:

Re: Limiting amount of choices from menu that can be selecte

#3 Post by Izzayuh »

Thank you!! I will definitely try that :)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], trailsiderice