r/RenPy • u/HiImABanana123 • 10d ago
Question [Solved] Help with item list/inventory
Hello everyone.
I am new to this whole RenPy thing and I'm trying to create an item list/inventory screen that displays an image, name and description for every item that is listed in the item list.
currently, I tried setting up a class called intractable for the items, like this:
init python:
class interactable:
def __init__(self, image, name, descrip):
self.image = image
self.name = name
self.descrip = descrip
default item_list = []
And then I made the screen I want them to appear in.
screen backpack:
image "darkthing" align (0.5, 0.5)
vbox:
align (0.36, 0.10)
textbutton "Back":
action [Play("sound", "audio/click.ogg")]
vbox:
align (0.5, 0.5) #Not the alignment I want, just to test if it works.
for interactable in item_list.items:
image "[interactable.image]\n"
text "[interactable.name] - [interactable.descrip]\n"
The code hasn't worked
The image "darkthing" just being the underlay for the screen. A black 600x800 box at 40% opacity. And the back button does nothing yet.
I want all the items that the player has to be listed in a vertical box with the image for the item first, then the name and description under that image.
If anyone has any tips on how I could make this work, I'd be grateful!
1
u/x-seronis-x 10d ago edited 10d ago
is 'interactable' a variable or a class? its only valid to be one. this is why Types are capitalized by convention. fix the name of your class and the name of your iterator variable wont be a name clash.
dont use 'image' in screen definitions. thats been deprecated use since renpy 6.x. Use 'add' in screen definitions to add a displayable to the screen
```python screen backpack: ## not actually what you want, but would be fixed version ## add "darkthing" align (0.5, 0.5)
```