Code: Select all
"You've arrived at the restaurant. It's very busy tonight, but you see a free spot where you and your date can sit down."
date.carol "Wow, my brother's restaurant has done a lot better than I expected! Look how busy it is!"
date.alien "So, this is the place you humans refer to as a 'restaurant'. How interesting."
date "It's really busy here, isn't it? It must be a good place."
Rather than say each line in sequence, Ren'Py will approach these lines as a set. The first few lines are specific, to either a character, or a type of character. If the speaker matches the conditions, then that line will be spoken, and not the others.
The last line in the set should always be a generic one, the line that 'anyone else' would say. Whether the line is said depends on if none of the other conditions were true for the speaker.
The last generic line also lets Ren'Py know that the set is over, and it should go back to reading lines normally until it meets the next set:
Code: Select all
"You've arrived at the restaurant. It's very busy tonight, but you see a free spot where you and your date can sit down."
date.carol "Wow, my brother's restaurant has done a lot better than I expected! Look how busy it is!"
date.alien "So, this is the place you humans refer to as a 'restaurant'. How interesting. And how crowded."
date "It's really busy here, isn't it? It must be a good place."
player "Hopefully we won't have to wait too long to order. What do you want to get?"
date.alien "I don't have the slightest idea of what any of these foods even are."
date "Hmm.. it's so hard to decide."
player "Well, I heard the fish was good."
The first thing you should do to use this system is to create a set of FilteredCharacter objects. FilteredCharacter objects are just like regular Character objects, except that
* You'll need to make them FilteredCharacter's so that the dialogue system recognizes them.
* Along with the usual keyword arguments, you can add extra keywords that give basic information about the character, such as gender, age, or personality.
Code: Select all
init python:
carol = FilteredCharacter("Carol",color="#ff0",gender="f",age=25,alien=False)
nooko = FilteredCharacter("Nooko",color="#0f0",gender="f",age=225,alien=True)
gorbo = FilteredCharacter("Gorbo",color="0a0",gender="f",age=171,alien=True)
alice = FilteredCharacter("Alice",color="#aaf",gender="f",age=21,alien=False)
player = FilteredCharacter("Player",color="#fff",gender="m",age=22,alien=False)
* You can refer to the variable names of the characters, such as 'carol' or 'nooko'. Ren'Py will realize that this is a line meant for that character only, and will only say it if the current speaker is exactly that character.
* If any of your fields set up in FilteredCharacter are booleans, you can use the name of the field as a test to see if it is True for the speaker. For instance, Nooko and Gorbo will speak lines that you've marked as 'alien'.
Custom Filters
If you need more flexibility, you can set up additional filters using the 'diction' object:
Code: Select all
diction.add_filter("human","speaker.alien == False")
diction.add_filter("girl","speaker.gender == 'f'")
diction.add_filter("boy","speaker.gender == 'm'")
diction.add_filter("drunk","speaker.beers >= 3")
The function 'add_filter' takes two arguments; the name of the filter (which you can then use for marking your dialogue), and the condition that the filter has to meet.
The condition is written in the same way that ConditionSwitch conditions are written, i.e. a basic Python statement. Note the use of the word 'speaker', which is a special variable that holds whoever is planning to speak.
If Tests
You can also use the filters, either the automatic ones or the ones you've created, in if-tests in your script.
Code: Select all
date.drunk "Ish.. ish's been greeeeat. I loooove you.."
date "Well, this has been a fine time. It was really nice getting to know you."
if date.carol:
jump meet_carol_brother
if date.alien:
jump sudden_monster_attack
* The code uses 'diction' and 'speaker' as reserved global variables, so don't use those names for your own purposes.
* Don't set a named variable in FilteredCharacter and then use that same name to title a filter - the filters are created as variables themselves, and you would just overwrite that name on the character. object.