- Sep 6, 2017
- 35
- 60
Hi guys, I'm trying to make an inventory that shows the available quantities of an owned item(number of quantities in the inventory screen in the bottom corner of the item).
This is the code:
From this point on I don't know how to move... I've tried to help myself with codes from other users but I can't get to the bottom of it...
My inventory screen:
Thanks in advance for the help!
This is the code:
Code:
init python:
class Item(object):
def __init__(self, name, cost=0, img="", description="", h_img=""):
self.name = name
self.cost = cost
self.img = img
self.description = description
self.h_img = h_img
class Inventory(object):
def __init__(self, money=0):
self.items = []
self.money = money
def get_item(self, item):
self.items.append(item)
def buy_item(self, item):
if money >= item.cost:
self.items.append(item)
self.money -= item.cost
def drop(self, item):
self.items.remove(item)
def earn_money(self, amount):
self.money += amount
def withdraw_money(self, amount):
self.money -= amount
My inventory screen:
Code:
screen inventory_window():
zorder 100
modal True
tag gg_inventory_window
key "mouseup_2" action Hide("nonexistent_screen")
key "h" action Hide("nonexistent_screen")
add "gg_dev"
add "inv_box"
add "inv_item_desc"
vpgrid:
cols 8
rows 18
xpos 565 ypos 310 spacing 9
draggable True
mousewheel False
ysize 320
yinitial 0
scrollbars "vertical"
side_spacing 20
for Item in inventory.items:
frame:
style "bagslot"
imagebutton:
idle Item.img
hover Item.h_img
if hovered_item == False:
hovered [SetVariable("hovered_item", True), SetVariable("selected_name", Item.name), SetVariable("selected_description", Item.description)]
else:
unhovered [SetVariable("hovered_item", False), SetVariable("selected_name", ""), SetVariable("selected_description", "")]
action NullAction()
for i in range(len(inventory.items), 250):
frame:
style "bagslot"
Last edited: