[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
Newbie
Posts: 23
Joined: Thu Jan 16, 2020 2:01 am
Contact:

[SOLVED]List and Index

#1 Post by GoldenD » Mon Jan 20, 2020 2:02 pm

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: 686
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: List and Index

#2 Post by gas » Mon Jan 20, 2020 2:06 pm

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.
10 ? "RENPY"
20 GOTO 10

RUN

GoldenD
Newbie
Posts: 23
Joined: Thu Jan 16, 2020 2:01 am
Contact:

Re: List and Index

#3 Post by GoldenD » Mon Jan 20, 2020 2:19 pm

Hi,
and sorry.

Apparently I didn’t read the dictionaries correctly.

Thanks

Post Reply

Who is online

Users browsing this forum: No registered users