[Solved] AttributeError: type object 'Player' has no attribute 'equipment'
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.
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.
[Solved] AttributeError: type object 'Player' has no attribute 'equipment'
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?
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.
- 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'
It seems that pc is not an object of type 'Player', but type itself.
< < insert Rick Cook quote here > >
- 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'
Are you sure that parentheses are there and nothing else overwrites pc anywhere?
< < insert Rick Cook quote here > >
- 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'
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.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot]