[SOLVED]List and Index

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
GoldenD
Regular
Posts: 43
Joined: Thu Jan 16, 2020 2:01 am
Contact:

[SOLVED]List and Index

#1 Post by GoldenD »

is it possible to have a list i call by a personnal string index and that would look like this :

Code: Select all

define listEvents = [
["Event1", False],
["Event2", False],
["Event3", False],
.../...   
]
I would like use this list giving the string ("Event1" for example) as index, and read or append its boolean value.

Clear ?
Last edited by GoldenD on Mon Jan 20, 2020 2:19 pm, edited 1 time in total.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: List and Index

#2 Post by gas »

EDIT (my bad).

That's exactly what dictionaries are made for.

Code: Select all

default mylist = {"Event1": False, "Event2": False}
and use default, not define, you want to apply some change.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

GoldenD
Regular
Posts: 43
Joined: Thu Jan 16, 2020 2:01 am
Contact:

Re: List and Index

#3 Post by GoldenD »

Hi,
and sorry.

Apparently I didn’t read the dictionaries correctly.

Thanks

Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot]