Page 1 of 1

How to make the first line of a menu dynamic?

Posted: Tue Jul 09, 2019 11:16 am
by jacob_ax
Hi everyone,
I'm trying to make something like this:

Code: Select all

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 :)

Re: How to make the first line of a menu dynamic?

Posted: Tue Jul 09, 2019 11:54 am
by DannX
You could try this:

Code: Select all

    # 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.

Re: How to make the first line of a menu dynamic?

Posted: Tue Jul 09, 2019 12:00 pm
by jacob_ax
Thanks!!!
:D