Code: Select all
class Girl(object):
def __init__(self):
self.gen_girl() # I generate the girl's name and stats here
self.traits = []
class Trait(object):
def __init__(self, name, effects):
self.name = name
self.effects = effects
Code: Select all
default TRAITS = [
Trait("Beautiful", "effect"),
Trait("Charming", "effect"),
Trait("Witty", "effect"),
Trait("Elegant", "effect")
]
Code: Select all
self.traits = [renpy.random.sample(TRAITS, 2)]
I want to get a list for the traits that were assigned, girl1 is an instance of Girl:
Code: Select all
screen test:
vbox:
xalign .5
yalign .5
for trait in girl1.traits:
text "Traits: {}.".format(trait.name)
AttributeError: 'list' object has no attribute 'name'.
I'm still learning the ropes so if there are any tips on how to fix this I would appreciate it a lot. Thank you.