Randomize dialogue

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
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Randomize dialogue

#1 Post by isobellesophia » Sat Sep 14, 2019 9:35 pm

Hello

I would like to have a randomize dialogue everytime a player types anything that hasn't been labeled.

Code: Select all

label user:
    $ user_input = renpy.input(prompt = "Type anything! If you want to leave, say 'Later or later' Or if you want to go places, type 'Lets go somewhere'.", allow="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ /.,'?!")

    $ user_input=user_input.lower().strip()

Code: Select all

label unlabeled:
   m "Hm? What do you want to talk about?" #This one is normal
   m "How about something else?" #I also want this to have a chance to get this dialogue when you typed an unlabeled dialogue.
Is it possible? Thank you.
I am a friendly user, please respect and have a good day.


Image

Image


User avatar
78909087
Veteran
Posts: 277
Joined: Sat Aug 16, 2014 2:33 pm
Completed: Dungeons and Don't Do It, Wake Up
Projects: Lethe
IRC Nick: Pacermist
Contact:

Re: Randomize dialogue

#2 Post by 78909087 » Sat Sep 14, 2019 9:41 pm

I can write this out in code a bit later, but you can check the entered text against your values with if/elif/else, then if it isn't already used, randomise a number between values and have each value = a different dialogue. Then, just jump to the referenced number using if/elif /else andddd done.


Random number generator https://www.renpy.org/doc/html/other.html#renpy-random
I am not friends with the sun.
Image

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: Randomize dialogue

#3 Post by isobellesophia » Sat Sep 14, 2019 9:45 pm

Ah, i forgot that RenPy also had a random variable, thanks!
I am a friendly user, please respect and have a good day.


Image

Image


Post Reply

Who is online

Users browsing this forum: Google [Bot], WillandBran