Code: Select all
# Python to define MC stat variables
label mc_stats_inventory:
# MC Health and Willpower amount
$ mc_bonus_hp = skill3_points
$ mc_hp_max = 50 + mc_bonus_hp
$ mc_hp = mc_hp_max
$ mc_bonus_wp = skill5_points
$ mc_wp_max = 50 + mc_bonus_wp
$ mc_wp = mc_wp_max
default mc_hp = 50
# Inventory python code
init python:
# What the items can do (add and remove)
class Inventory():
def __init__(self, items, no_of_items):
self.items = items
self.no_of_items = no_of_items
# Add the item - to add item to inventory use "$ inventory.add_item(item)"
def add_item(self, item):
self.items.append(item)
self.no_of_items += 1
# Remove the item - to remove item from inventory use "$ inventory.remove_item(item)"
def remove_item(self, item):
self.items.remove(item)
self.no_of_items -= 1
# How the items show (image and effect)
class InventoryItem():
def __init__(self, image, description, action):
self.image = image
self.description = description
self.action = action
# MC inventory open
screen mc_inventory():
add "bg-inventory"
modal True
# Close inventory Button
imagebutton auto "button-check-%s":
align (0.5, 0.05)
action [Hide(), ToggleScreen("mc_hud")]
hbox:
align(0.08, 0.25)
textbutton "Items":
action Show("mc_inventory_items")
textbutton "Weapons":
action NullAction()
textbutton"Special":
action NullAction()
screen mc_inventory_items():
# Inventory Grid
grid 4 16:
spacing 10
align(0.04, 0.3)
for item in inventory.items:
frame:
maximum(0, 0)
imagebutton:
idle [item.image]
action [item.action, RemoveFromSet(inventory.items, item)]
tooltip [item.description]
$ tooltip = GetTooltip()
if tooltip:
nearrect:
focus "tooltip"
prefer_top True
text tooltip
# Inventory starting space (None)
default inventory = Inventory([],0)
# Bandages item
default bandages = InventoryItem("item-bandages", "+25 Health", Function(bandages_effect, 25))
init python:
def bandages_effect(amount):
store.mc_hp += 25
if mc_hp > mc_hp_max:
store.mc_hp = min(mc_hp_max, mc_hp + amount)