'Quest' object has no attribute 'Id'... Attribute Error

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
gabowave
Newbie
Posts: 10
Joined: Sat Jul 08, 2023 4:15 pm
Contact:

'Quest' object has no attribute 'Id'... Attribute Error

#1 Post by gabowave »

Hello, I am currently having a potentially very simple issue to fix and I just haven't gotten around to finding the source. I am trying to make quests that upon calling a method are set to completed. Problem is that once I call the method it says that the attribute id doesn't exist. here is the BBcode Markdown.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/reusable.rpy", line 110, in script
    python:
  File "game/reusable.rpy", line 119, in <module>
    questlist.RemoveQuest(1)
  File "game/quests.rpy", line 21, in RemoveQuest
    if o.Id == id:
AttributeError: 'Quest' object has no attribute 'Id'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/reusable.rpy", line 110, in script
    python:
  File "C:\Users\joscr\OneDrive\Documents\renpy-8.1.1-sdk\renpy\ast.py", line 1138, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\joscr\OneDrive\Documents\renpy-8.1.1-sdk\renpy\python.py", line 1122, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "game/reusable.rpy", line 119, in <module>
    questlist.RemoveQuest(1)
  File "game/quests.rpy", line 21, in RemoveQuest
    if o.Id == id:
AttributeError: 'Quest' object has no attribute 'Id'

Windows-10-10.0.22621 AMD64
Ren'Py 8.1.1.23060707
Rockwood 0.18v "Startup[WIP]"
Thu Jul 20 20:56:54 2023
This is the error it's throwing at me. Here is my code for reference.

Code: Select all

init python:

    class Quest ():
        def __init__(self, name, description, Id, available = False, started = False, completed = False):
            self.name = name
            self.description = description
            self.available = available
            self.started = started
            self.completed = completed
            self.Id = Id

    class QuestList ():
        def __init__(self):
            self.quests = []
            
        def AddQuest(self, quest):
            self.quests.append(quest)
        
        def RemoveQuest(self, id):
            for i, o in enumerate(self.quests):
                if o.Id == id:
                    self.quests[i].completed = True
                    self.quests[i].available = False
                else:
                    n('did not work')

            
    
#QuestList
default quest_01 = Quest("Use Bathroom Keys", "Diana is trying to use the bathroom and I have the keys to open the door.", 1, True, True, False)
default quest_02 = Quest("Talk to Diana", "Diana seems to want to talk, You should out what she wants.", 2, True, False, False)
default questlist = QuestList()
Any suggestions are appreciated and if anyone finds a way to fix this I would greatly appreciate it thanks! :)

enaielei
Veteran
Posts: 293
Joined: Fri Sep 17, 2021 2:09 am
Organization: enaielei
Tumblr: enaielei
Deviantart: enaielei
Github: enaielei
Skype: enaielei
Soundcloud: enaielei
itch: enaielei
Discord: enaielei#7487
Contact:

Re: 'Quest' object has no attribute 'Id'... Attribute Error

#2 Post by enaielei »

I don't see anything wrong here. Probably try force recompiling your scripts through the launcher? And ICYMI, make sure that the changes in the script are saved.

gabowave
Newbie
Posts: 10
Joined: Sat Jul 08, 2023 4:15 pm
Contact:

Re: 'Quest' object has no attribute 'Id'... Attribute Error

#3 Post by gabowave »

enaielei wrote: Fri Jul 21, 2023 12:10 am I don't see anything wrong here. Probably try force recompiling your scripts through the launcher? And ICYMI, make sure that the changes in the script are saved.
Unfortunately this did not work. I think I'll just look for another way to do what I want. Still.. I wonder why it doesn't want to work. Makes no sense to me. Thanks anyway.

enaielei
Veteran
Posts: 293
Joined: Fri Sep 17, 2021 2:09 am
Organization: enaielei
Tumblr: enaielei
Deviantart: enaielei
Github: enaielei
Skype: enaielei
Soundcloud: enaielei
itch: enaielei
Discord: enaielei#7487
Contact:

Re: 'Quest' object has no attribute 'Id'... Attribute Error

#4 Post by enaielei »

My best guess is you don't have this "Id" attribute in the earlier versions of your game, then you created saves at those said versions. Now you added the "Id" attribute and tried to load those saves.
Other than that, I don't see anything wrong with the code.

gabowave
Newbie
Posts: 10
Joined: Sat Jul 08, 2023 4:15 pm
Contact:

Re: 'Quest' object has no attribute 'Id'... Attribute Error

#5 Post by gabowave »

enaielei wrote: Sat Jul 22, 2023 10:59 pm My best guess is you don't have this "Id" attribute in the earlier versions of your game, then you created saves at those said versions. Now you added the "Id" attribute and tried to load those saves.
Other than that, I don't see anything wrong with the code.
Fixed it somehow... I commented the code block with the method RemoveQuest, added a workaround, saw your post... Uncommented the method and now it works!

I have no clue why or how but.. ??¿¿ it works now so I don't care. Thank you so much though!

Post Reply

Who is online

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