Streamline 'used' buttons/options?

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
LeonDaydreamer
Veteran
Posts: 335
Joined: Sun Feb 22, 2015 1:20 am
Projects: A Near Dawn, Put A Sock In It!, Ghosts Are Good Hosts
Contact:

Streamline 'used' buttons/options?

#1 Post by LeonDaydreamer » Sun Oct 23, 2016 5:14 pm

Hi, I recently released a game: Put A Sock In It!

In it, we had a system in which previously selected options were faded out. My programmer used individual variables to keep track of this, and simply show a colored button for a selection that has never been played before or a grayed out button for a selection that has been played before.

However, if you have 1000 options, it would require 1000 variables to do it this way, and I know that Ren'Py doesn't exactly have arrays (only lists)... not sure how I could use those with an index of options. I was hoping to get a programmer's perspective on this subject about whether there was a straightforward way of doing this (and/or if there was already a feature implemented in Ren'Py that I'm not aware of)...

I also considered using renpy.seen_label(label) to keep track of previously selected options, but seen_label is persistent data, I wasn't sure if there was an equivalent of this for every new game you make?

Thanks!
ImageImageImageImage

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Streamline 'used' buttons/options?

#2 Post by Ocelot » Sun Oct 23, 2016 5:36 pm

I know that Ren'Py doesn't exactly have arrays (only lists)
In Python, lists are what in other languages you would call arrays/vectors/whatever: dynamic sequence container. You can use it as array.

Or iterate over it in more Pythonic way. Something like:

Code: Select all

default choices = [
    ('drink tea', False, 'drink.tea'),
    ('drink coffee', False, 'drink.coffee'),
    ('drink sode', False, 'drink.out_of_soda'),
]

#In game script:
screen choose_drink:
    vbox:
        for choice_text, seen, menu_label in choices:
            if not seen:
                # create active button
                # it should set second value in tuple in corresponding list element to True and return third tuple element
            else:
                # create inactive button

label choose_menu:
    call screen choose_drink
    jump expression _return
< < insert Rick Cook quote here > >

User avatar
LeonDaydreamer
Veteran
Posts: 335
Joined: Sun Feb 22, 2015 1:20 am
Projects: A Near Dawn, Put A Sock In It!, Ghosts Are Good Hosts
Contact:

Re: Streamline 'used' buttons/options?

#3 Post by LeonDaydreamer » Mon Oct 24, 2016 7:36 pm

Ocelot wrote:In Python, lists are what in other languages you would call arrays/vectors/whatever: dynamic sequence container. You can use it as array....
Alright, so you would recommend using lists to handle this. Thanks Ocelot! :)
ImageImageImageImage

Post Reply

Who is online

Users browsing this forum: Bing [Bot]