Vannyr
New Member
- Aug 13, 2017
- 6
- 4
Hey there friends! 
Long time lurker here. So I am currently developing a sandbox visual novel (first time) and it has been so much fun so far, but now I am in front of my dreaded inventory screen and I got it to work....ALMOST! But there is one thing I just cant wrap my head around, so maybe some of you kind people can help me before I rip all of my hair out. I've been at it for hours and hours and just... cant figure it out. Its driving me crazy haha.
So as some other games, I am using Milkymans Inventory System:
I am coding on Renpy 8, so this is Python 3.
I envision my game to have 3 different inventories: General / Gifts / Clothes
For now I am just coding the General tab. Thats why I named everything "genitem, genname" etc. I would just alter the code for the other inventories.
Here is the code for the inventory itself:
I don't have any other code there, just wanted to test it with adding first.
This is the command for adding items in the script:
And this is my inventory screen on the General Tab:
It displays the images of the items (genimg) themselves correctly side to side as programmed in the grid.
When I hover over one of the items, it shows me all the names of the items and descriptions in the General Inventory. I understand that its because I asked it to with "a." because it lists everything in that Container.
But for the life of me I cant figure out how to ONLY display the name and description of the item the player is currently hovering over. Every other code I tried so far gave me an error. I've searched everything up and down for an answer but came up short. Did I already make a mistake with displaying the images themselves?
And I dont even dare to ask how to program a function that opens a second inventory tab when the first 18 items of the first General Inventory Page are full. These two are the only things standing in my way of finally putting my troubles to rest.
I would be thrilled if some of you talented people could help me out! Other than this, coding as been a breeze and so much fun. Thank you so much in advance and much love from Germany!
Vannyr
Edit: Formatting, spelling etc
Long time lurker here. So I am currently developing a sandbox visual novel (first time) and it has been so much fun so far, but now I am in front of my dreaded inventory screen and I got it to work....ALMOST! But there is one thing I just cant wrap my head around, so maybe some of you kind people can help me before I rip all of my hair out. I've been at it for hours and hours and just... cant figure it out. Its driving me crazy haha.
So as some other games, I am using Milkymans Inventory System:
You must be registered to see the links
I am coding on Renpy 8, so this is Python 3.
I envision my game to have 3 different inventories: General / Gifts / Clothes
For now I am just coding the General tab. Thats why I named everything "genitem, genname" etc. I would just alter the code for the other inventories.
Here is the code for the inventory itself:
Python:
#default inventory for general
default genbackpack = GenContainer()
#default general inventory items
default generalgodofwaifu = GeneralItem('God Of Waifu', 'A good game', 'images/Items/itemgodofwaifu.png')
default generalsupersmashsisters = GeneralItem('Super Smash Sisters', 'A smashing game', 'images/Items/itemsupersmashsisters.png')
init python:
##### GENERAL ITEMS CODE #####
class GeneralItem(object):
def __init__(self, genname, gendescription, genimg):
self.genname = genname
self.gendescription = gendescription
self.genimg = genimg
class GeneralInvItem(object):
def __init__(self, genitem, genamount):
self.genitem = genitem
self.genamount = genamount
class GenContainer(object):
def __init__(self):
self.geninventory = []
def add_genitem(self, genitem, genamount=1):
if genitem in [a.genitem for a in self.geninventory]:
self.geninventory[[a.genitem for a in self.geninventory].index(genitem)].genamount += genamount
else:
self.geninventory.append(GeneralInvItem(genitem,genamount))
return
This is the command for adding items in the script:
Python:
$ genbackpack.add_genitem(generalgodofwaifu)
$ genbackpack.add_genitem(generalsupersmashsisters)
And this is my inventory screen on the General Tab:
Python:
default GeneralItemhov = "Unhovered"
screen inventoryuigeneral1:
## Some frames etc here that I am leaving out since it isnt important###
hbox:
grid 6 3:
xpos 300
ypos 150
spacing 21
for a in genbackpack.geninventory:
imagebutton:
idle a.genitem.genimg
hover a.genitem.genimg
action NullAction()
hovered SetVariable("GeneralItemhov", "Hovered")
unhovered SetVariable("GeneralItemhov", "Unhovered")
showif GeneralItemhov == "Hovered":
vbox:
xpos 300
ypos 800
for a in genbackpack.geninventory:
text a.genitem.genname
text a.genitem.gendescription
When I hover over one of the items, it shows me all the names of the items and descriptions in the General Inventory. I understand that its because I asked it to with "a." because it lists everything in that Container.
But for the life of me I cant figure out how to ONLY display the name and description of the item the player is currently hovering over. Every other code I tried so far gave me an error. I've searched everything up and down for an answer but came up short. Did I already make a mistake with displaying the images themselves?
And I dont even dare to ask how to program a function that opens a second inventory tab when the first 18 items of the first General Inventory Page are full. These two are the only things standing in my way of finally putting my troubles to rest.
I would be thrilled if some of you talented people could help me out! Other than this, coding as been a breeze and so much fun. Thank you so much in advance and much love from Germany!
Vannyr
Edit: Formatting, spelling etc
Last edited: