Character Name substitution
There are a few functions that can be used to refer to a particular character. The main one is %CharacterName%. This function has two parameters, both of which are optional. The first is the key of the character you want to get the name of. If this parameter is omitted, then the output will depend where the function is called. If it is called from within the edit character form, the character is assumed to be that character. If it is called from anywhere else, the character is assumed to be the player. A second parameter is the type of pronoun that could be used to replace this name. If this parameter is omitted it is assumed to be subjective.
Proper Name or Descriptor?
Characters in ADRIFT can have either a Proper Name (the actual name of the character) and/or a descriptor (short description of what the character is). Generally when you encounter someone for the first time you would not refer to them by name until you had been introduced in some way. So if we create a character with Proper Name "Hamish", and give him a descriptor "a" "short stocky" "man", then when we first encounter Hamish in the game it would be more realistic to introduce him with his descriptor, e.g. "A short stocky man is here", rather than "Hamish is here."
The way ADRIFT deals with this is by the use of a property "Is this character known to the Player". If a character has this property selected, the %CharacterName% function will return the Proper Name of the character. If the character does not have this property and they also have a descriptor, the %CharacterName% function will return the descriptor. During the game, once the Player has been introduced to a character, setting this property will then change how the character is referred to in the game.
Pronouns are words that can be substituted for a noun. In the case of characters, the nouns are the character's name or descriptor. ADRIFT will replace any functions for character's names with pronouns if the name is referenced more than once unambiguously. It does this to create more natural prose.
When you create text output in ADRIFT, you may add different bits of text in different places. Say, for example, you have the description for character Hamish as simply "Hamish stands nearby." Say you also have an event that runs every few turns and outputs "Hamish kicks a stone about idly." If you happened to examine the character at the same time as the event runs, the output would be:
Hamish stands nearby. Hamish kicks a stone about idly.
Clearly this doesn't sound very natural. So if both of these character names are replaced with the CharacterName function, ADRIFT will automatically substitute the second name with the pronoun, producing:
Hamish stands nearby. He kicks a stone about idly.
Notice that the name Hamish has been substituted with the word 'he'. This is the third person objective pronoun. So how did ADRIFT know to substitute that and not some other pronoun? Well, you have to tell it which sort of pronoun should be used. If you don't say which should be used, it assumes you want to use a subjective pronoun. In most cases, the character being referenced is the subject of the sentence, and so this assumption is correct. Subjective pronouns are I, you, he, she etc. If you can replace one of these words in your sentence, the pronoun will be subjective.
So what if you had an event that output the text "A gust of wind comes out of nowhere, almost blowing Hamish over." We could not replace "Hamish" with "he" in this scenario. This is because Hamish is not the subject of the sentence, the wind is. Hamish is the object of this sentence, therefore we need to tell ADRIFT that this pronoun should be the objective pronoun. Objective pronouns are me, you, him, her etc. To define the name as an objective pronoun, we must give the CharacterName function an additional parameter, 'object'. So the function becomes %CharacterName[CharacterKey, object]%. We could also explicitly define the earlier function as %CharacterName[CharacterKey, subject]%, but the pronoun is assumed to be subjective when the parameter is omitted.
If the same character is both the subject and the object of the sentence (for example, "%CharacterName[subject]% throws a ball to %CharacterName[object]%), then this would normally be replaced with "he throws a ball to him" (in the third person perspective, see below). ADRIFT will automatically realise that the subject and the object are the same, and therefore switch automatically to the reflective pronoun (myself, yourself, himself, herself). So this example would become "he throws a ball to himself".
Games in ADRIFT can be told in the first (I, me, my etc), second (you, your etc) or third (he, him, his etc) person perpective. When replacing a noun with a pronoun, ADRIFT will pick the relevant pronoun taking the perspective into account. The standard library is set up so that all messages output correctly regardless of the perspective, as any names are substituted with the selected perspective pronouns. Building perspective awareness into the tasks themselves also allows us to reuse the same task output for different characters.
Different perspectives affects more than just the pronouns. There may be supporting words that are only relevant for a particular perspective. ADRIFT provides a way of dealing with this by allowing you to specify values for each perspective. The syntax for this is similar to the Advanced Command Construction in tasks, where three options must be supplied within square brackets, separated by a forward slash, i.e.
[first perspective output/second perspective output/third perspective output]
The perpective used to work out which entry to use from the list is the previous one referred to by the %CharacterName% function.
For example, we could define the following:
"%CharacterName[%character%] [am/are/is] sitting on a stool. %CharacterName[%character%]% look at %CharacterName[%character%, object]% watch."
In first person perspective this becomes:
"I am sitting on a stool. I look at my watch."
In second person perspective this becomes:
"You are sitting on a stool. You look at your watch."
And in third person perspective this becomes (assuming the character is male):
"He is sitting on a stool. He looks at his watch."
Notice that  defines that nothing is output for first and second person perspectives, and only outputs in third person perspective.