Random Dialogue at the Push of a Button, random.randint Problem

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
Tow4352
Newbie
Posts: 7
Joined: Sat Aug 22, 2020 11:27 am
Contact:

Random Dialogue at the Push of a Button, random.randint Problem

#1 Post by Tow4352 » Sat Aug 22, 2020 12:21 pm

Hi there. I try to have an imagebutton randomly pick between five pieces of dialogue, but sadly something is not working out for me here. Anyone have any idea what I am doing wrong?

Code: Select all

                if icc == 6:
                    action random.randint(6, 10)
                    if random.randint == 6:
                        action Jump ("icc6")
                    if random.randint == 7:
                        action Jump ("icc7")
                    if random.randint == 8:
                        action Jump ("icc8")
                    if random.randint == 9:
                        action Jump ("icc9")
                    if random.randint == 10:
                        action Jump ("icc10")

OrsonDeWitt
Regular
Posts: 35
Joined: Thu Dec 06, 2018 3:23 am
Contact:

Re: Random Dialogue at the Push of a Button, random.randint Problem

#2 Post by OrsonDeWitt » Sat Aug 22, 2020 12:41 pm

Make the imagebutton go to label x,
then:

Code: Select all

label x:
	jump expression renpy.random.choice( ["icc6", "icc7", "icc8", "icc9", "icc10"] )

Tow4352
Newbie
Posts: 7
Joined: Sat Aug 22, 2020 11:27 am
Contact:

Re: Random Dialogue at the Push of a Button, random.randint Problem

#3 Post by Tow4352 » Sat Aug 22, 2020 1:35 pm

Huh. Not what I expected solution-wise, seeing as this didn't use randint. Though it works swimmingly and with a whole lot less code than I had. Thank you for the great help! =D

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]