Ren'Py Struggling while making inventory items stackable

Darknerious

Newbie
Game Developer
Apr 19, 2022
61
247
Hi, i am struggling to make an inventory for my game, but the level of coding to make one is beyond my intelligence, so I'm editing a template I found on the internet. syrup lite rpg. And i am working on it to make it to my liking. But I got stuck. I can't get the count attribute to increment... does anyone know why or how to do it? Or any other alternative to edit this template. Since it really has everything I want except that it doesn't stack items in one slot. Here's where I stuck. pickup function is working but the attribute count isn't incrementing.
init -2 python:
class InvItem(store.object):
def __init__(self, name, image, value, info, id, count, cost=[]):
self.image = image
self.value = int(value)
self.info = info
self.id = id
self.count = count
self.cost = cost

def pickup(self, amount=1):
self.see()
while amount>0:
if self.id not in inv:
inv.append(self.id)
self.count += 1
amount -= 1

define item_water = (_("Plain Ol' Water"), "item water", 2,
_("A fundamental ingredient for alchemy and potion-making. It's clean enough to drink."), "item_water", 0)

label start:
$ InvItem(*item_water).pickup(2)
####screen to show it:
$ thisitem = InvItem(*set_item(selected_item))
text "x {}" .format(thisitem.count) xalign 0