TLDR; Version of my issue:
I'm making an inventory system for the game and I have decided to use classes in order to streamline things and for it to work better down the line. I am using classes for both the character stats and the inventory...
My issue comes up with a certain attribute I put in...
This attribute contains a small set which refers to individual slots of armor the character can put on.
I have used the SetVariable function in order to fill the "helm" portion of the armor slot.
Code: Select all
SetVariable (MC.armor["helm"], itemselect)
Full Code:
character definition
Code: Select all
init python:
class Player:
def __init__(self, hp, mp, ki, mood, level):
self.hp = hp
self.max_hp = hp
self.mp = mp
self.max_mp = mp
self.ki = ki
self.max_ki = ki
self.mood = mood
self.armor = {"helm": None, "chest": None, "legs": None, "arms": None}
self.weapon = None
level = level
MC = Player (100, 0, 0, "Neutral", 1)
Code: Select all
init python:
class items:
def __init__(self, name, weight, price):
self.name = name
self.weight = int(weight)
self.price = int(price)
init python:
class armor(items):
def __init__(self, name, weight, price, defense, type):
items.__init__(self, name, weight, price)
self.defense = int(defense)
self.type = type
init python:
class Armory:
def __init__(self):
self.inventory =[]
armory = Armory()
Code: Select all
screen armoryscreen():
modal True
imagebutton auto "background_%s" action SetVariable ("itemselect", "Empty")
text "Normal Items"
textbutton "Close" xpos .05 ypos .9 action [Hide ('armoryscreen')]
textbutton "Key Items" action [Hide ("armoryscreen"), Show ('inventoryscreen')] xpos 0.85 ypos .9
vpgrid:
ypos .1
xpos .3
cols 2
xspacing 200
yspacing 5
for items in armory.inventory:
textbutton "[items.name]" action SetVariable ("itemselect", items)
for i in range(len(armory.inventory), 20):
vbox
if isinstance(itemselect, armor):
if itemselect.type == "helm":
textbutton "Equip Helm" action SetVariable (MC.armor["helm"], itemselect) xpos 0.85 ypos .2
textbutton "Unequip Helm" action SetVariable (MC.armor["helm"], None) xpos 0.85 ypos .3