Applying persistent data to items in a list

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
AikoYamamoto
Newbie
Posts: 9
Joined: Sun Nov 04, 2018 12:02 am
Contact:

Applying persistent data to items in a list

#1 Post by AikoYamamoto »

Is there anybody who can help me with this? I've been strugling for this about 2 hours and can't get an idea how to apply persistent statement from renpy for each tip in a list using an id_name.

For example:

charachter_a "blah-blah-blah-blah"
$persistent.tip(id_name) = unlocked"

Here's my code:

init -1 python:
class Tips:
def __init__(self, number, name, category, desc, unlockable, id_name):
self.name = name
self.category = category
self.number = number
self.desc = desc
self.unlockable = unlockable
self.id_name = id_name

show_desc = None

massive = [
Tips("01", "Lab", "Random", "qweqe qwe2312 qwlke mqwlk meqwe", "locked", "lab"),
Tips("02", "University", "Building", "qweqe qwe qwlke mqasdasd1231dasd as dasd asd12 dadqw asd wlk meqwe", "locked", "tdu")
]

screen glossary():
tag menu
add "menu/tips/tips_bg.png"
viewport:
xpos 50 ypos 100 xsize 300 ysize 500
scrollbars "vertical"
spacing 3
draggable True
mousewheel True
arrowkeys True
vbox:
for tip in massive:
if tip.unlockable == "unlocked":
textbutton tip.number +" "+ tip.name action SetVariable("show_desc", tip) text_size 16
else:
textbutton tip.number + " ????" action NullAction() text_size 16
if show_desc:
text show_desc.desc

imagebutton idle "menu/clearlist/back_btn.png" xalign 0.95 yalign 0.95 focus_mask True action Return()

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: Applying persistent data to items in a list

#2 Post by isobellesophia »

Hello there!

You can visit this site if you love to.

viewtopic.php?t=51990

It is a glossary screen or whatever its called.

It is along with persistent data which you can unlock whatever you wanted.

Hope i could help. :P
I am a friendly user, please respect and have a good day.


Image

Image


Post Reply

Who is online

Users browsing this forum: DragoonHP, Kocker, Ocelot, Semrush [Bot]