Echo Hollow

Gender-Bending Interactive Stories! :D

User Tools

Site Tools


libtf:documentation:api:util

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
libtf:documentation:api:util [2018/02/25 12:21] – created leelibtf:documentation:api:util [2018/09/24 17:31] (current) – removed lee
Line 1: Line 1:
-[[libtf:documentation:api:start|<-- Back]] 
- 
- 
-====== LibTF.Util====== 
- 
-Miscellaneous internal utility functions that don't seem to fit anywhere else. 
- 
-You probably won't every need to use any of these, except maybe //.capitalize()//. 
- 
-===== Methods ===== 
- 
- 
-==== LibTF.Util.commaList( list ) ==== 
- 
-  * **Arguments:** 
-    * **//list://** an array of strings. 
-  * **Returns:** (String)  A comma-separated description of the list. 
-  * **Throws:** Nothing. 
- 
-Returns a comma-separated description of the list, including "and", or "nothing" if the list is empty. 
- 
-<code javascript> 
-alert( LibTF.commaList([ "a two-dollar pistol", "a Stetson hat", "a shotgun" ]) ); 
-// prints "a two-dollar pistol, a Stetson hat, and a shotgun" 
-</code> 
- 
-<code javascript> 
-alert( LibTF.commaList([ "a two-dollar pistol", "a Stetson hat" ]) ); 
-// prints "a two-dollar pistol and a Stetson hat" 
-</code> 
- 
-<code javascript> 
-alert( LibTF.commaList([ "a two-dollar pistol" ]) ); 
-// prints "a two-dollar pistol" 
-</code> 
- 
-<code javascript> 
-alert( LibTF.commaList([ ]) ); 
-// prints "nothing" 
-</code> 
- 
-==== LibTF.Util.capitalize( s ) ==== 
- 
-  * **Arguments:** 
-    * **//s://** a string to capitalize 
-  * **Returns:** (String)  A string matching //s//, but with the first character capitalized. 
-  * **Throws:** Nothing. 
- 
-Returns a string matching //s//, but with the first character capitalized. 
- 
-FIXME: This doesn't work if the first character is a quotation mark or other punctuation, or a number.  Does it need to? 
- 
-<code javascript> 
-// given that some_widget.name == "widget"... 
-alert( LibTF.Util.capitalize(tfGet("some_widget").aName) + " sure is a good thing to have!" ); 
-// prints "A widget sure is a good thing to have!" 
-</code> 
- 
-==== 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(tfGet("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(tfGet("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(tfGet("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(tfGet("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(tfGet("joe"),true,"jump") ); // "he jumps" 
-alert( LibTF.Util.youHeShe(tfGet("joe"),false,"jump") ); // "you jump" 
-alert( LibTF.Util.youHeShe(tfGet("joe"),true,"are","is")+" jumping" ); // "he is jumping" 
-alert( LibTF.Util.youHeShe(tfGet("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(tfGet("joe"),true,"jump") ); // "He jumps" 
-alert( LibTF.Util.YouHeShe(tfGet("joe"),false,"jump") ); // "You jump" 
-alert( LibTF.Util.YouHeShe(tfGet("joe"),true,"are","is")+" jumping" ); // "He is jumping" 
-alert( LibTF.Util.YouHeShe(tfGet("joe"),false,"are","is")+" jumping" ); // "You are jumping" 
-</code> 
- 
- 
-[[libtf:documentation:api:start|<-- Back]] 
  
libtf/documentation/api/util.1519590109.txt.gz · Last modified: 2018/02/25 12:21 by lee