Updating an instance of a class

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
Adrian_DVL
Regular
Posts: 141
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

Updating an instance of a class

#1 Post by Adrian_DVL »

Hi mates!
So, I have two classes to store quests in my game and to show them to the player every time he enters a screen, just like this:

Code: Select all

    class Quest(renpy.store.object):
        def __init__(self, subj=".png", descr=""):
            self.subj = subj
            self.descr = descr


    class Qlist(renpy.store.object):
        def __init__(self):
            self.quests = []
        def add(self, quest):
            self.quests.append(quest)
        def ok(self, quest):
            self.quests.remove(quest)
Then I have the instances of the Quest class initialized with a default, like this:

Code: Select all

default hope1 = Quest("hope", "Meet {color=#3397fe}Hope{/color} at the gym.")
Now I want to update an instance on the go. I mean: I want a player to add a quest to his qlist and, while the quest is still there, update the subj or the descr of the quest, reflecting the changes on the game. As I have the instances declared, I can't do this by simply changing the instance code, so I tried making a method to update the quests and stuff like that but I couldn't get it done properly.

Can someone help me with this?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot]