If a certain item is already in the inventory, the button will disable itself.
Eg. if I have an apple in the inventory, the button to purchase an apple will disable itself because I already have an apple.
I've scoured the documentation looking for something that will work around this, but I've found nothing. Any help would be appreciated!
This is my code:
Code: Select all
init python:
class Item(renpy.store.object):
def __init__(self, name, image, price=0.0):
self.name = name
self.image = image
self.price = price
default shop_inventory = [apple,orange,pear]
default inventory = []
default money = 15
label start:
define apple = Item("Apple","items/apple.png",5)
define orange = Item("Orange","item/orange.png",5)
define pear = Item("Pear","item/pear.png",5)
call screen shop
return
screen shop:
modal True
frame:
xsize 400 ysize 400 ypadding 10 xpadding 10 xalign .5 yalign .5
vbox:
for i in shop_inventory:
if money >= i.price:
textbutton i.name action [AddToSet("inventory",i),SetVariable("money",money-i.price)]
else:
textbutton i.name action NullAction()