Code: Select all
init python:
import renpy.store as store
class Clothing(store.object):
def __init__(self, name, description, aspects, location, amount = 1):
self.name = name
self.description = description
self.aspects = []
self.location = location
self.amount = amount
class Inventory(store.object):
def __init__(self, name):
self.name = name
def equip(self, clothing_item):
if clothing_item.location == "head":
store.head_slot_name = clothing_item.name
store.head_slot_descrip = clothing_item.description
if clothing_item.location == "torso":
store.torso_slot_name = clothing_item.name
store.torso_slot_descrip = clothing_item.description
default ball_cap = Clothing("ball cap", "a worn baseball cap", ["casual"], "head", 1)
default tshirt = Clothing("T-shirt", "a plain yellow shirt", ["casual"], "torso", 1)
default top_hat = Clothing("top hat", "a posh top hat", ["fancy", "silly"], "head", 1)
default head_slot_name = ""
default head_slot_descrip = ""
default player_style = ""
default player_outfit = Inventory("player")
label start:
$ player_outfit.equip(ball_cap)
"The thing on your head slot is [head_slot_name]. It is [head_slot_descrip]."
The problem I am having is that I can't seem to find a way to check what is inside the Aspects list in my Clothing class instances when I am passing them into a function like equip up there.
Code: Select all
def style_check(self, clothing_item):
if "casual" in clothing_item.aspects:
store.player_style = "Relaxed"
else:
store.player_style = "This didn't work."
Code: Select all
def style_check(self, clothing_item):
for i in clothing_item.aspects:
if (i == "casual"):
store.player_style = "Relaxed"
else:
store.player_style = "This didn't work."
Code: Select all
def style_check(self, clothing_item):
if ("casual" in clothing_item.aspects):
store.player_style = "Relaxed"
else:
store.player_style = "This didn't work."
Ideally I'd like to be able to check the aspects list in every equipment slot worn by the player, tally the number of times a certain value like "casual" appears, and set the player's style based on the value that appears the most between them all.
But I'm apparently missing something fundamental about how to check list values from a passed instance inside a method.
Code: Select all
label start:
$ player_outfit.equip(ball_cap)
"The thing on your head slot is [head_slot_name]. It is [head_slot_descrip]."
$ player_outfit.style_check(ball_cap)
"Your style is [player_style]."
Code: Select all
"The thing on your head slot is ball cap. It is a worn baseball cap."
"Your style is This didn't work.."