hi, ive been trying to do the an inventory/store system, theres is a part where i set a inventory for each character so im able to give them items, but im getting hard stuck. the problem is that i cannot successfully append the item from my inventory to the characters inventory, the characters are made with objects and their inventories are contained inside a object , also have another class for my items so it looks something like this.
Code: Select all
class Item:
global items_avaliable
global store_sections
items_avaliable = []
def __init__(self, created_for, cost, imagen, description, category):
self.created_for = created_for
self.cost = cost
self.imagen = im.Scale(imagen, 152, 196)
self.description = description
self.category = category
red_sweater_for_gwen = Item("gwen_", 500, "/images/screens/Store/gwen_sweater_red.png", "red_sweater_for_gwen", clothes)
class Character_info:
def __init__(self, ui_image, ui_color):
self.ui_image = ui_image
self.ui_color = ui_color
self.inventory = []
gwen_ = Character_info("/images/screens/Store/gwen_menu.png", "#7A1800")
Code: Select all
def give_item(self, character):
getattr(character, "inventory").append(self)
im trying to trigger the give_item() as an action for a button
Code: Select all
action Function(getattr(item_being_used, "give_item"), character)
keep in mind that this is for general purposes and not just for the character of gwen_, so any solutions to the main problem are accepted, it doesnt have to be this specific, ty for your time