elhlyn wrote: ↑Mon Mar 15, 2021 10:15 pm
so to add characters, I have to modify the "Person" class? or what would be the format to create characters?
You create a character every time you write
Person(...). For the game, you create them only when you need one. For example, if you want the player to select one of the characters to add to the party, you can create as many as you'd like to provide a selection for the player, but once the player "buy" a character, you add this character to the party list and discard the others. The player can anytime select one of the characters that are in the party as shown in the example code.
If you want to add a new character(s) to the pre_defined character list you can directly add them to the pre_defined.
You definitely need to modify "Person" class to fit your needs. For example, if you want to create a particular character (let's say by index in pre_defined list) you can put an argument in the __init__ method:
Code: Select all
def __init__ (self, i = None):
if i == None: # If index is not specified - random character based on pre_defined
n = len(Person.pre_defined)-1
i = renpy.random.randint(0,n)
self.name = Person.pre_defined[i]['name']
...
Then Person(i = 0) create "Tom", Person(i = 1) create "Jill"