Numerical choices in choices menu?

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
tohtamish
Regular
Posts: 65
Joined: Thu Apr 29, 2010 4:56 am
Contact:

Numerical choices in choices menu?

#1 Post by tohtamish »

Like in rpg games - where you can press numbers on keyboard to answer. Is it possible to do someway?

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Numerical choices in choices menu?

#2 Post by philat »

Choices are stored in a list (referenced as items in the choice screen). You can modify the choice screen to show numbers for each item and use the key statement (https://www.renpy.org/doc/html/screens.html#key ) to trigger choices.

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Numerical choices in choices menu?

#3 Post by Alex »

You need to modify the choice screen, smth like

Code: Select all

screen choice(items):
#    style_prefix "choice"
#
#    vbox:
#        for i in items:
#            textbutton i.caption action i.action
    style_prefix "choice"
    for n, i in enumerate(items, 1): # n would be the number starting from 1
        if n<10:
            key str(n) action i.action
        textbutton str(n) + ") " + i.caption action i.action

Post Reply