[Solved]Recognizing a random quote

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
Cazad0ra
Newbie
Posts: 22
Joined: Wed May 19, 2021 3:53 pm
Contact:

[Solved]Recognizing a random quote

#1 Post by Cazad0ra »

Hi! I was looking the other day for a way to make a character say random quotes and I found this code, which works like a charm:

Code: Select all

menu:
        "What do you want to do?"
        "Talk to Nizara":
                show nizara talk
                $ quotes=random.choice(nizara_quotes)
                niz "[quotes]"
                jump intro
                

Code: Select all

default nizara_quotes = ["Example quote 1", "Example quote 2", "Example quote 3"]
What I was wondering is, is it possible to make it so that if you have seen a certain quote, something else happens? Say, if you saw "Example quote 3" you get an extra menu choice? sort of like renpy.seen_image

Thanks!
Last edited by Cazad0ra on Wed Jun 09, 2021 6:08 pm, edited 1 time in total.

User avatar
emz911
Regular
Posts: 103
Joined: Fri Jun 23, 2017 2:23 pm
Contact:

Re: Recognizing a random quote

#2 Post by emz911 »

easiest way is to record it as a variable, if you have seen it, change the variable

Code: Select all

default seen_quote3 = False

#and under the dialogue
"Talk to Nizara":
     show nizara talk
     $ quotes=random.choice(nizara_quotes)
     niz "[quotes]"
     if quotes == "Example quote 3":
           $ seen_quote3 = True
     jump intro
For a new menu choice:

Code: Select all

"New choice" if seen_quote3:
      #whatsoever
Last edited by emz911 on Wed Jun 09, 2021 4:42 pm, edited 1 time in total.

User avatar
zmook
Veteran
Posts: 421
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: Recognizing a random quote

#3 Post by zmook »

Cazad0ra wrote: Wed Jun 09, 2021 11:19 am What I was wondering is, is it possible to make it so that if you have seen a certain quote, something else happens? Say, if you saw "Example quote 3" you get an extra menu choice? sort of like renpy.seen_image

Code: Select all

default seen_quotes = set()	# set instead of list because sets ignore duplicates
menu:
        "What do you want to do?"
        "Talk to Nizara":
                show nizara talk
                $ quote=random.choice(nizara_quotes)
                $ seen_quotes.add(quote)
                niz "[quote]"
                jump intro
        "Make fun of Nizara" if "Example quote 3" in seen_quotes:
          	jump something_else_happens
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3792
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Recognizing a random quote

#4 Post by Imperf3kt »

To do that just use the variable as shown above, but from within a menu

Code: Select all

label example1:
    menu:
        "option 1" if seen_quote3:
            "you've seen quote 3"
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Cazad0ra
Newbie
Posts: 22
Joined: Wed May 19, 2021 3:53 pm
Contact:

Re: Recognizing a random quote

#5 Post by Cazad0ra »

Actually, with these methods combined you solved three other doubts I had!!
Thanks a ton!

Post Reply

Who is online

Users browsing this forum: No registered users