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.
define bman = Character("Bartender")
$ number = renpy.random.randint(1,3)
menu ask_for_a_drink:
#First we have three condition that will decide what will appear in the textbox (the bartender is talking)
if number == 1:
bman "What's your poison?"
if number == 2:
bman "You thirsty?"
if number == 3:
bman "What would you like today?"
#Then the choices that will appear on the menu screen
"Vodka":
some text and actions...
"Jin":
some text and actions...
"Wine":
some text and actions...
the problem is, this doesn't work. Is there a way to deal with this?
Thanks
# A list with possible greetings for the bartender
$ bman_texts = ["What's your poison?", "You thirsty?", "What would you like today?"]
# pick one of them with renpy.random.choice and store it in a variable called t
$ t = renpy.random.choice(bman_texts)
menu ask_for_a_drink:
bman "[t]" #have bman character speak the selected text
"Vodka":
# some text and actions
pass
"Jin":
# some text and actions
pass
"Wine":
# some text and actions
pass
With renpy.random.choice, the game randomly selects one element from a list, in this case, one string of text. Then you interpolate it with [] in renpy dialogue. This saves typing since you don't need randint and a lot of if statements.