[Resolved] List item bug
Posted: Thu Jun 14, 2018 11:38 pm
Hi Renpy pros!
I've run into a snag recently. I'm pretty new to renpy and moderately new to python as a whole.
I followed the cookbook guide over here for an inventory
(I removed the weight functionality though)
Important bits of code from there that I'm using look like this.
I modified InvItem to include a def __str__
I am having trouble displaying items in the backpack though.
https://i.imgur.com/O1KSecq.png
Test code for this is here.
I'm kind of stuck here. I just wanted it to display text (for now) for the item that is in the backpack.
I've run into a snag recently. I'm pretty new to renpy and moderately new to python as a whole.
I followed the cookbook guide over here for an inventory
(I removed the weight functionality though)
Important bits of code from there that I'm using look like this.
I modified InvItem to include a def __str__
Code: Select all
class InvItem(object):
def __init__(self, item, amount):
self.item = item
self.amount = amount
def __str__(self):
return str(self.item)
https://i.imgur.com/O1KSecq.png
Test code for this is here.
Code: Select all
if not backpack.inventory:
text "Backpack Empty"
else:
text "Backpack Contents:"
for i in range(len(backpack.inventory)):
$ temp = backpack.inventory[i]
text "[temp]"
textbutton ("Add Poison") action Function(backpack.add_item, item_poison)
textbutton ("Add Potion") action Function(backpack.add_item, item_potion)