Need help with a kinky point and click in Renpy

I’m working on a follow-up to my previous Renpy project, but I’m looking to make this one into a point and click rather than a Visual novel.

I managed to set up an inventory system, by stealing some code that I found on youtube.

The code is for a drag and drop inventory, but I’d rather items be automatically removed from your inventory as soon as you click on the object that needs them.

I have a python function for removing items from your inventory:

def removeInventoryItem(item):
    item.destroy()
    inventory_sprites.pop(inventory_sprites.index(item))
    inventory_items.pop(inventory_items.index(item.type))
    repositionInventoryItems()

and another for interacting with a bookshelf

elif item.type == “bookshelf”:
if “book” in inventory_items:
removeInventoryItem(“book”)

Currently, when I interact with the bookshelf while the book is in my inventory, I get this error

File"game/script.rpy", line 2011 in removeInventoryItem
item.destory()
Attribute Error: ‘str’ object has no attribute ‘destroy’

Hopefully the issue is my own inexperience and can be easily fixed.

if “book” in inventory_items:

In this case “book” refers to the text string “book”

same here

elif item.type == “bookshelf”:

I haven’t seen your code for the class object item… but… it’s VERY likely removing all your
"" will instantly fix all your problems.

Assuming everything else is perfect (which it might not be), this would be what you wanted.

elif item.type == bookshelf:
if book in inventory_items:
removeInventoryItem(book)
2 Likes

Thanks for your reply! I did end up resolving the issue, but it was a bit more complicated than I initially thought.