Page 1 of 1

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

Posted: Thu Sep 08, 2022 5:38 pm
by Doeny
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?

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

Posted: Thu Sep 08, 2022 5:53 pm
by Ocelot
It seems that pc is not an object of type 'Player', but type itself.

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

Posted: Thu Sep 08, 2022 5:58 pm
by Doeny
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()

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

Posted: Thu Sep 08, 2022 6:14 pm
by Ocelot
Are you sure that parentheses are there and nothing else overwrites pc anywhere?

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

Posted: Thu Sep 08, 2022 7:06 pm
by Doeny
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.

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

Posted: Thu Sep 08, 2022 9:11 pm
by laure44
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.

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

Posted: Thu Sep 08, 2022 11:15 pm
by Doeny
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!