Change values in an arraylist

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
neometalero
Regular
Posts: 193
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Change values in an arraylist

#1 Post by neometalero »

I want to change values in an arraylist.

I have this list

Code: Select all

default persistent.gallery_1_list = [
    ["KnightArmorConcept01", 1],
    ["KnightArmorConcept02", 0],
    ["CapeNHoodConcept",0],
    ["CrossWeaponConcept01",0],
    ["CrossWeaponConcept02",0],
    ["CrossWeaponFinalConcept",0],
    ["IdealusFaceConcept",0],
    ["IdealusTattoosConcept",0],
    ["SebastianFaceConcept",0],
    ]
I want to change the 1rst element of the list, the cero value to 1. so It would look like

Code: Select all

["KnightArmorConcept01", 0]
How can I do that?
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Change values in an arraylist

#2 Post by Remix »

Array / list indices are referenced by numeric indices, so
$ persistent.gallery_1_list[0][1] = 0
would reference the first index of persistent.gallery_1_list (the ["KnightArmorConcept01", 1] bit) and then reference the second index of that
Frameworks & Scriptlets:

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

Re: Change values in an arraylist

#3 Post by Alex »

neometalero wrote: Mon Aug 02, 2021 5:10 pm I want to change values in an arraylist.

I have this list

Code: Select all

default persistent.gallery_1_list = [
    ["KnightArmorConcept01", 1],
    ["KnightArmorConcept02", 0],
    ["CapeNHoodConcept",0],
    ["CrossWeaponConcept01",0],
    ["CrossWeaponConcept02",0],
    ["CrossWeaponFinalConcept",0],
    ["IdealusFaceConcept",0],
    ["IdealusTattoosConcept",0],
    ["SebastianFaceConcept",0],
    ]
I want to change the 1rst element of the list, the cero value to 1. so It would look like

Code: Select all

["KnightArmorConcept01", 0]
How can I do that?
Try it like

Code: Select all

$ persistent.gallery_1_list[0][1] = 0
first item of persistent.gallery_1_list has index [0], and this item is a list of two items, and we want to change second item that has index [1].

edit: I'm slooow...

User avatar
neometalero
Regular
Posts: 193
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Change values in an arraylist

#4 Post by neometalero »

Remix wrote: Mon Aug 02, 2021 5:51 pm Array / list indices are referenced by numeric indices, so
$ persistent.gallery_1_list[0][1] = 0
would reference the first index of persistent.gallery_1_list (the ["KnightArmorConcept01", 1] bit) and then reference the second index of that
tks! that worked just fine. I didn't knew what the correct syntaxes was.
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

Post Reply

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot]