I'm not sure how you've set your items up, but the way I do an inventory I have items as a class, and the inventory as a screen. Then I also have a class for each character, part of which contains a list for their inventory. If you only have one character of course you wouldn't need that and you could have just one list for your inventory, but I digress...
What exactly do you want to be able to do with the inventory? Do you just want it to list what items are on hand, or do you want players to be able to go into the inventory and view detailed descriptions of the items, or be able to use the items in certain cases?
Anyway, my coding is a little like this:
Let's say $ items = [] is an empty list that we're going to hold inventory items in. Then
Code:
screen inventory:
frame:
xalign 0.0
yalign 0.0
vbox:
for i in items:
text i
In this case, each item has to be a string so that it will show up properly as text. This gives you a vertical list of each item, with each one on a new line.
Now, if you have the items as a class, with perhaps a name and some properties you could change it to something like
Code:
for i in items:
text i.name
fairly easily.
If you want something to actually happen from the inventory use a textbutton instead of text, and then you can add some actions. Let's say I have items as a class with a name and a short description, like so:
Code:
class item:
def __init__(self, name, description):
self.name = name
if description == "":
self.description = "A random thing."
else:
self.description = description
(That bit's in a python block and an init block)
And then I define my items like this:
Code:
$ sweatshirt = item("Sweatshirt", "A red jumper.")
Now I could have my inventory screen like so:
Code:
screen inventory:
vbox:
xalign 0.0
yalign 0.0
frame:
vbox:
for i in items:
textbutton i.name hovered SetVariable("data", i.description) unhovered SetVariable ("data", "My inventory.") action SetVariable ("data", "Clicked!")
null height 20
frame:
text data
Remembering to set initial values for all the vairables we've used somewhere
Code:
$ sweatshirt = item("Sweatshirt", "A red jumper.")
$ items = []
$ data = "My inventory."
Now adding something to the inventory with append as usual
Code:
$ items.append(sweatshirt)
will let it show up in the inventory, which can be seen or hidden with
show screen inventory
hide screen inventory
Now we can hover over the items to view a description of them, or click on them for something else to happen.
Now, you wanted to only open the inventory when there's something in it. The best way is to set up another screen. Something like this:
Code:
screen showinv:
if not items == []:
frame:
xalign 0.0
yalign 0.0
textbutton "Open Inventory" action (Hide("showinv"), Show("inventory"))
Let's add a bit to our previous inventory code to let us close it...
Code:
screen inventory:
vbox:
xalign 0.0
yalign 0.0
frame:
vbox:
for i in items:
textbutton i.name hovered SetVariable("data", i.description) unhovered SetVariable ("data", "My inventory.") action SetVariable("data", "Clicked!")
textbutton "Close Inventory" action (Hide("inventory"), Show("showinv"))
null height 20
frame:
text data
Now use
show screen showinv
at the start of your game (or somwehere) instead of show inventory. We'll now have a button to open the inventory that will only show up when there's something actually in the inventory.
EDIT:
As for where to put the coding for the screens, you can put them in the file with the predefined screens, or put them at the top of your regular code, it doesn't really matter.
As for what action you want to happen when you hover over or click on an item, that's up to you. Here are the possible actions:
http://www.renpy.org/doc/html/screen_actions.html