An each time random text [solved]

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
Turtle Joshua
Newbie
Posts: 7
Joined: Thu Jun 21, 2018 12:12 pm
Contact:

An each time random text [solved]

#1 Post by Turtle Joshua »

Hello everyone !
I have a question about random in renpy.

I tried to make a random quote each time the narrator's speaking using renpy.random.choice () but unfortunately the quote is always the same. I tried to figure out how to do this but I didn't seem to find what I was looking for.

Here are some parts of my code :

Code: Select all

default quotes=["The weather's good today","I'm bored.","I wanna sleeeeeep !!","Hard-work is really important guys"]

# - - - - - - - - - - Game starts here - - - - - - - - - -
label start:
$ rd_quotes=renpy.random.choice(quotes) #pick a random tense from the list "quotes"
scene black
m "Someone's there ?"
narrator " Maybe or maybe not."
m "Who're you ?"
narrator "[rd_quotes]"
m "What ?"
narrator "[rd_quotes]"
m "Didn't understand."
narrator "[rd_quotes]"
m "Huh..."
narrator "[rd_quotes]"
m "Well I..."
narrator "[rd_quotes]"
m "Okay,I give up."
return
should I use another function or variable ?

I also went here : https://www.renpy.org/doc/html/other.ht ... npy-random
Last edited by Turtle Joshua on Mon Jun 25, 2018 2:37 am, edited 1 time in total.

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: An each time random text

#2 Post by xavimat »

you only ask renpy once to choose a quote, so the variable rd_quotes is always the same.
Repeat the random line:

Code: Select all

default quotes=["The weather's good today","I'm bored.","I wanna sleeeeeep !!","Hard-work is really important guys"]

# - - - - - - - - - - Game starts here - - - - - - - - - -
label start:
    scene black
    m "Someone's there ?"
    narrator " Maybe or maybe not."
    m "Who're you ?"
    $ rd_quotes=renpy.random.choice(quotes) #pick a random tense from the list "quotes"
    narrator "[rd_quotes]"
    m "What ?"
    $ rd_quotes=renpy.random.choice(quotes) #pick a random tense from the list "quotes"
    narrator "[rd_quotes]"
    m "Didn't understand."
    $ rd_quotes=renpy.random.choice(quotes) #pick a random tense from the list "quotes"
    narrator "[rd_quotes]"
    m "Huh..."
    $ rd_quotes=renpy.random.choice(quotes) #pick a random tense from the list "quotes"
    narrator "[rd_quotes]"
    m "Well I..."
    $ rd_quotes=renpy.random.choice(quotes) #pick a random tense from the list "quotes"
    narrator "[rd_quotes]"
    m "Okay,I give up."
    return
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)

User avatar
Turtle Joshua
Newbie
Posts: 7
Joined: Thu Jun 21, 2018 12:12 pm
Contact:

Re: An each time random text

#3 Post by Turtle Joshua »

Aah, so we have to tell each time we want a new quote ! I understand now, it makes sense !
Thank you, xavimat !

Post Reply

Who is online

Users browsing this forum: crowcinthus, Yahoo [Bot]