[Solved] AttributeError: type object 'Player' has no attribute 'equipment'

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
Doeny
Regular
Posts: 26
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

[Solved] AttributeError: type object 'Player' has no attribute 'equipment'

#1 Post by Doeny » Thu Sep 08, 2022 5:38 pm

So I'm trying to make an equipment screen, but for some reason I'm heading an error which main part you can see below:

File "renpy/common/000statements.rpy", line 609, in execute_call_screen
store._return = renpy.call_screen(name, *args, **kwargs)
File "game/inventory.rpy", line 10, in execute
screen inventory():
File "game/inventory.rpy", line 10, in execute
screen inventory():
File "game/inventory.rpy", line 13, in execute
hbox:
File "game/inventory.rpy", line 14, in execute
vbox:
File "game/inventory.rpy", line 30, in execute
frame:
File "game/inventory.rpy", line 32, in execute
if pc.equipment["head"] != None:
File "game/inventory.rpy", line 32, in <module>
if pc.equipment["head"] != None:
AttributeError: type object 'Player' has no attribute 'equipment'

The problem is I've got no idea what could posiibly go wrong, since I fell like tested every solution i could think of, and current state of it's main code looks like that:

init python:

class Player:
def __init__(self):
self.equipment = {"head": None, "chest": None, "boost": None, "legs": None, "neck": None, "ring": None, "shield": None, "tat": None, "weapon": None}

Can somebody tell me what's wrong about it?
Last edited by Doeny on Thu Sep 08, 2022 11:16 pm, edited 1 time in total.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1882
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: AttributeError: type object 'Player' has no attribute 'equipment'

#2 Post by Ocelot » Thu Sep 08, 2022 5:53 pm

It seems that pc is not an object of type 'Player', but type itself.
< < insert Rick Cook quote here > >

Doeny
Regular
Posts: 26
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

Re: AttributeError: type object 'Player' has no attribute 'equipment'

#3 Post by Doeny » Thu Sep 08, 2022 5:58 pm

Ocelot wrote:
Thu Sep 08, 2022 5:53 pm
It seems that pc is not an object of type 'Player', but type itself.
What do you mean? I have pc defined in the script file :
default pc = Player()

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1882
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: AttributeError: type object 'Player' has no attribute 'equipment'

#4 Post by Ocelot » Thu Sep 08, 2022 6:14 pm

Are you sure that parentheses are there and nothing else overwrites pc anywhere?
< < insert Rick Cook quote here > >

Doeny
Regular
Posts: 26
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

Re: AttributeError: type object 'Player' has no attribute 'equipment'

#5 Post by Doeny » Thu Sep 08, 2022 7:06 pm

Ocelot wrote:
Thu Sep 08, 2022 6:14 pm
Are you sure that parentheses are there and nothing else overwrites pc anywhere?
Yeah, it's the only time I use it. Nothing's overwriting it.

User avatar
laure44
Regular
Posts: 60
Joined: Mon Mar 08, 2021 10:55 pm
Projects: Arkan'sTower, Gemshine Lorelei!
Location: France
Contact:

Re: AttributeError: type object 'Player' has no attribute 'equipment'

#6 Post by laure44 » Thu Sep 08, 2022 9:11 pm

I did test it on a fresh game and it works fine. Perhaps you should try to rename pc to something else, just to make sure the error doesn't come from that.

Doeny
Regular
Posts: 26
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

Re: AttributeError: type object 'Player' has no attribute 'equipment'

#7 Post by Doeny » Thu Sep 08, 2022 11:15 pm

laure44 wrote:
Thu Sep 08, 2022 9:11 pm
I did test it on a fresh game and it works fine. Perhaps you should try to rename pc to something else, just to make sure the error doesn't come from that.
I changed it and now it works well. Thank you very much!

Post Reply

Who is online

Users browsing this forum: GetOutOfMyLab, Google [Bot], Ocelot