Ask coding questions

← Back to all posts
Save the Kingdom Good Text Adventure Game
PenguinLunatic (2)

First Choose any character, then once you equip something it shows your inventory, but how come all of them change when slotNumber can only be one thing? (Info on line 1067 in main.py)

Answered by Spacecraft (152) [earned 5 cycles]
View Answer
Comments
hotnewtop
Spacecraft (152)

That's way more code than I'm willing to wade through, but I'm assuming that they all change because the player values all = None, just like slotNumber = None. This is the only way I can see for them to all change at once.
Figure out why player.accessorySlot1 and all the others within storeInventoryHelp function don't have any values and that should help you solve the problem.

PenguinLunatic (2)

@Spacecraft ok i will see what i can do

Spacecraft (152)

@AlexSilyaev I think this may be the source of your problem. From the file hero.py:

#inventory
    #The Rings, Amulets, Necklaces
    self.accessorySlot1 = None
    self.accessorySlot2 = None
    self.accessorySlot3 = None
    #The Weapons
    self.weaponSlot1 = None
    self.weaponSlot2 = None
    self.weaponSlot3 = None
    #The Armor
    self.armorSlot1 = None
    self.armorSlot2 = None
    self.armorSlot3 = None
    #The Potions
    self.potionSlot1 = None
    self.potionSlot2 = None
    self.potionSlot3 = None

All of these values are set to None. When you get to the if statements starting on line 1071, every single line evaluates as True, because they are all defined as None, which matches the variable slotNumber.

Spacecraft (152)

@AlexSilyaev Was this the source of the error making them all the same value? I see you've changed that section of code but you've still left the question as unanswered.

PenguinLunatic (2)

@Spacecraft I have finished it yes thank you, just doing if they are all full. Thanks for your help :D

Highwayman (1483)

just from taking a quick first look at it.... maybe change all the ifs to elifs?

PenguinLunatic (2)

@Highwayman Yes that is what i had a first, but then the first still is True, but if you want me too i can change it back

Highwayman (1483)

If you already tried that then I guess it doesn't make much sense to revert it again. besides it looks like you and Spaceecraft are on a better track anyways. @AlexSilyaev