Disable an option after it's chosen a set amount of times

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
User144
Newbie
Posts: 1
Joined: Mon Jun 13, 2016 2:13 am
Contact:

Disable an option after it's chosen a set amount of times

#1 Post by User144 »

How do I make it so you can pick a choice from a menu in Renpy a set amount of times before it becomes unavailable for the day?

For example

label example:
menu:
"Choice 1":
"blah blah blah"
jump example
"Choice 2":
"something something"
jump example
"Choice 3":
"This and that"
"etc"
jump example

While I want to be able to pick more than one or the same one several times I don't want it to be an infinite amount of times.

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Disable an option after it's chosen a set amount of time

#2 Post by IrinaLazareva »

Code: Select all

init:
    $ sdf = 0
    $ adf = False   
    
label start:
    ##...
    
 

label example:
    if sdf == 5:
        jump nexto
    menu:
        "Choice 1":
            "blah blah blah"
            $ sdf += 1
            jump example
        "Choice 2":
            "something something"
            $ sdf += 1
            jump example
        "Choice 3":
            "This and that"
            $ sdf += 1
            jump example
        "Bonus (Only ONE try)" if adf == False:
            "..."
            $ sdf += 1
            $ adf = True
            jump example            
            
label nexto:
    "ОК"        

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Disable an option after it's chosen a set amount of time

#3 Post by xavimat »

Code: Select all

label new_day:
    
    ## Assuming there are three choices
    $ choi = [0, 0, 0]
    $ times = 3
    
label example:
    
    menu:
        "Choice 1" if choi[0] < times:
            $ choi[0] += 1
            "Bla bla"
        "Choice 2" if choi[1] < times:
            $ choi[1] += 1
            "Bla bla"
        "Choice 3" if choi[2] < times:
            $ choi[2] += 1
            "Bla bla"
        "Another Option":
            "You need an option that will always be visible."
            "Otherwise the menu could be empty and the game blocked."                
            
    jump go_on
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: Google [Bot]