I would like to make a button that makes a RANDOM CHOICE

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
Automatic
Newbie
Posts: 3
Joined: Thu Sep 01, 2011 12:23 pm
Contact:

I would like to make a button that makes a RANDOM CHOICE

#1 Post by Automatic » Thu Sep 01, 2011 12:33 pm

Hello there,

I would like to make a button that makes a RANDOM CHOICE. Ok, so I have a menu button that, when clicked goes to a certain point (label) in the game. But I would like this button, when clicked to go to a random label out of, say a set of 3 choices of labels.

How do I do this? Any help would be very much appreciated.

Thank you.

Auto.

User avatar
Alphonse
Regular
Posts: 105
Joined: Tue Aug 26, 2008 7:32 pm
Contact:

Re: I would like to make a button that makes a RANDOM CHOICE

#2 Post by Alphonse » Thu Sep 01, 2011 1:36 pm

Code: Select all

    menu:
        "Where to go?"
        "Go home.":
            "You went home."
        "Go somewhere. Anywhere.":
            $ randomnum = renpy.random.randint(1,3) # (randomize between 1 and 3)
            if randomnum == 1:
               jump library
            if randomnum == 2:
                jump school
            if randomnum == 3:
                jump restaurant
I think this will probably work.

Automatic
Newbie
Posts: 3
Joined: Thu Sep 01, 2011 12:23 pm
Contact:

Re: I would like to make a button that makes a RANDOM CHOICE

#3 Post by Automatic » Wed Sep 14, 2011 11:52 am

Cool, thank you so much. I'll give it a go. :D

Post Reply

Who is online

Users browsing this forum: No registered users