All you need to do to manipulate this is to define two lists, one will keep the item names, the other will keep the amount. This way you won't have to append any lists with new items, just define the items beforehand. You can define a list like any variable anywhere in the code, but these have to be defined before you open the inventory menu.
Code: Select all
$ item_name = ["cat","dog","unkle steve"]
$ item_amount = [0,0,0]
you can now modify the amount of item like this (note, all lists start with a 0 item, not 1):
Code: Select all
$ item_amount[0] += 1 # <- adds one to the first item
$ item_amount[1] = 5 # <- sets the amount of the second item to 5
Code: Select all
show screen simple_example_inventory
Code: Select all
hide screen simple_example_inventory
Code: Select all
$ a = 0
$ b = 0
Code: Select all
screen simple_example_inventory: # <- this is how you define the beginning of a screen
frame xalign 0.5 ypos 0.1:
vbox:
for a in range (0,len(item_name)): # <- for every item on the list between 0 and list length
if item_amount[a] > 0: # <- checks if the amount of that item is more than 0
$ b = item_name[a]
text "[b]" # <-display the item name
for example you can show the amount of the item
Code: Select all
screen simple_example_inventory:
frame xalign 0.5 ypos 0.1:
vbox:
for a in range (0,len(item_name)):
if item_amount[a] > 0:
$ b = variable_name[a]
$ c = variable_amount[a] # <-checks the amount of the item
text "[b]: [c]" # <-displays both values
you can turn the items into buttons, you would probably have to define a new list for actions
Code: Select all
$ item_action = ["petthecat", "lickthedog", "biteunkle"]
Code: Select all
screen simple_example_inventory:
frame xalign 0.5 ypos 0.1:
vbox:
for a in range (0,len(item_name)):
if item_amount[a] > 0:
$ b = item_name[a]
$ c = item_amount[a]
$ d = item_action[a] # <- checks the name of the corresponding label on the list
textbutton "[b]: [c]" action Jump(d)# <-turns the items into buttons which jump to the corresponding label but you need to have a label with the corresponding name somewhere or it will error
This is only a starter, you can expand or modify it in a variety of ways. For example you could add a variable based always on-screen inventory button which opens or closes the inventory. You could change the inventory buttons into pictures and so on.