This is how you loop through a dictionary and output it's content via renpy.say ... I would've never figured this out on my own.
Code: Select all
define dict_people = {
"Bob": aPerson("Bob", 34),
"Zoe": aPerson("Zoe", 54)}
# if this isn't -1, it won't work. i have no idea why.
init -1 python:
class aPerson():
def __init__ (self, str_name, str_age):
self.s_name = str_name
self.age = str_age
def say_data():
for k,v in dict_people.items():
renpy.say("", "{0} is {1.s_name} aged {1.age}".format(k,v))
label start:
$ say_data()
Code: Select all
define personTed = aPerson("Ted", 76)
define personNuget = aPerson("Nuget", 98)
#this adds the entries
$ dict_people.update({"Ted": personTed})
$ dict_people.update({"Nuget": personNuget})