Both sides previous revisionPrevious revision | |
libtf:documentation:api:util [2018/09/24 17:31] – lee | libtf:documentation:api:util [2018/09/24 17:31] (current) – removed lee |
---|
==== LibTF.Util.yourHisHer( person, thirdPerson ) ==== | |
| |
* **Arguments:** | |
* **//person://** the person for which to return the adjective. | |
* **//thirdPerson ://** True if output should be in third-person, or False if it should be in second-person. | |
* **Returns:** (String) The appropriate adjective given the person's sex and //thirdPerson//. | |
* **Throws:** Nothing. | |
| |
If //thirdPerson// is True, returns "his", "her", or "their" depending on whether the given Person's femininity Transformable indicates that they are male, female, or androgynous respectively. | |
| |
If //thirdPerson// is False, returns "your". This is useful for when the same passage/code is intended to generate text for both the player character and NPCs. | |
| |
<code javascript> | |
// if Joe is male... | |
alert( "There is a fire on " + Util.yourHisHer(tf("joe"),true) + " head!" ); | |
// prints "There is a fire on his head!" | |
</code> | |
| |
<code javascript> | |
// if Joe is female... | |
alert( "There is a fire on " + Util.yourHisHer(tf("joe"),true) + " head!" ); | |
// prints "There is a fire on her head!" | |
</code> | |
| |
<code javascript> | |
// regardless of Joe's sex, if Joe is the player character and we pass thirdPerson=false... | |
alert( "There is a fire on " + Util.yourHisHer(tf("joe"),false) + " head!" ); | |
// prints "There is a fire on your head!" | |
</code> | |
| |
==== LibTF.Util.YourHisHer( person, thirdPerson ) ==== | |
| |
This method is identical to //.yourHisHer()//, except that the first letter of the returned string is capitalized. | |
| |
<code javascript> | |
alert( Util.YourHisHer(tf("joe"),true) + " head is on fire!" ); | |
// prints "His head is on fire!" | |
</code> | |
| |
==== LibTF.Util.youHeShe( person, thirdPerson, youTheyVerb=null, heSheVerb=null ) ==== | |
| |
* **Arguments:** | |
* **//person://** the person for which to return the sentence fragment. | |
* **//thirdPerson ://** True if output should be in third-person, or False if it should be in second-person. | |
* **//youTheyVerb://** optional verb to output on you/they choice. | |
* **//heSheVerb://** optional verb to output on he/she choice. | |
* **Returns:** (String) A sentence fragment. | |
* **Throws:** Nothing. | |
| |
Chooses "he", "she", "they", or "you" in the same way as //.yourHisHer()//. | |
| |
If a //youTheyVerb// has been included, it will be appended to the return value if "you" or "they" is chosen. | |
| |
If **no** //heSheVerb// has been included, but "he" or "she" is chosen, then the //youTheyVerb// will have an "s" appended to it, and will be appended to the return value. Otherwise, if a //heSheVerb// **is** included, then it will be appended instead. | |
| |
<code javascript> | |
alert( LibTF.Util.youHeShe(tf("joe"),true,"jump") ); // "he jumps" | |
alert( LibTF.Util.youHeShe(tf("joe"),false,"jump") ); // "you jump" | |
alert( LibTF.Util.youHeShe(tf("joe"),true,"are","is")+" jumping" ); // "he is jumping" | |
alert( LibTF.Util.youHeShe(tf("joe"),false,"are","is")+" jumping" ); // "you are jumping" | |
</code> | |
| |
==== LibTF.Util.YouHeShe( person, thirdPerson, youTheyVerb, heSheVerb ) ==== | |
| |
This method is identical to //.youHeShe()//, except that the first letter of the returned string is capitalized. | |
| |
<code javascript> | |
alert( LibTF.Util.YouHeShe(tf("joe"),true,"jump") ); // "He jumps" | |
alert( LibTF.Util.YouHeShe(tf("joe"),false,"jump") ); // "You jump" | |
alert( LibTF.Util.YouHeShe(tf("joe"),true,"are","is")+" jumping" ); // "He is jumping" | |
alert( LibTF.Util.YouHeShe(tf("joe"),false,"are","is")+" jumping" ); // "You are jumping" | |
</code> | |
| |