Python Forum

Full Version: [pygame] Inventory problems. Weapons equipped to wrong slot
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been working on this inventory for so long. i finally made big progress on it but I have a problem.

Problem - When buying an item it is successfully put into inventory. The only problem is that it takes the original weapon. The original weapon is still there but does nothing when being equipped. Instead, the new weapon takes equips the original weapon.

I have my code in github here - https://github.com/Sheepposu/Destination - It can also be installed and tested for visual purposes. All the pictures should be updated into the picture folder. TIA for your help
Quote:
    def equipChange(self, receive, equips=None, n=None):
        if receive:
            return self.equips
        elif not receive:
            if n in self.availableSlots:
                equipsList = list(equips)
                if Counter(equipsList).most_common(1) == [(n, 2)]:
                    equipsList.remove(n)
                equipsTuple = tuple(equipsList)
                equ = 0
                equ2 = 0
                for eq in equipsTuple:
                    equ += eq
                for eq2 in self.equips:
                    equ2 += eq2
                if equ != equ2:
                    self.equips = equips
                else:
                    equipsList = list(equipsTuple)
                    equipsList.remove(n)
                    equipsTuple = tuple(equipsList)
                    self.equips = equipsTuple
        time.sleep(.5)

Help me to help you:
- what does receive mean?
- what's equips, and how is it different from self.equips?
- what's the equipsList for?
- what does this mean?
            equ = 0
            equ2 = 0
            for eq in equipsTuple:
                equ += eq
            for eq2 in self.equips:
                equ2 += eq2
            if equ != equ2:
                self.equips = equips
- If receive is true it will send self.equips (It is to be received)
- equips is the self.equips with the new equip
- I was having problems when creating the new equip, I don't remember all the details but, I had to turn it into a list, remove something, and then retuple it.
- That was something about deciding, did they click the same slot, did they click a different slot, if they clicked the same slot it would do something that messed up the inventory and so I added that to fix it.

Also sorry, let me point out the lines responsible for this part of the code. Starting on line 781 is the inventory class. giveItem starts on line 882, and openShop starts on line 756
Are we looking at the same file? Line 781 involves opening cabins, and 882 is about passwords.
Very sorry about that, it is now updated.
Just updated it again
Sorry if my code is messy or confusing