This is an old revision of the document!
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().
Returns a comma-separated description of the list, including “and”, or “nothing” if the list is empty.
alert( LibTF.commaList([ "a two-dollar pistol", "a Stetson hat", "a shotgun" ]) ); // prints "a two-dollar pistol, a Stetson hat, and a shotgun"
alert( LibTF.commaList([ "a two-dollar pistol", "a Stetson hat" ]) ); // prints "a two-dollar pistol and a Stetson hat"
alert( LibTF.commaList([ "a two-dollar pistol" ]) ); // prints "a two-dollar pistol"
alert( LibTF.commaList([ ]) ); // prints "nothing"
Returns a string matching s, but with the first character capitalized.
: This doesn't work if the first character is a quotation mark or other punctuation, or a number. Does it need to?
// given that some_widget.name == "widget"... alert( LibTF.Util.capitalize(tf("some_widget").aName) + " sure is a good thing to have!" ); // prints "A widget sure is a good thing to have!"
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.
// if Joe is male... alert( "There is a fire on " + Util.yourHisHer(tf("joe"),true) + " head!" ); // prints "There is a fire on his head!"
// if Joe is female... alert( "There is a fire on " + Util.yourHisHer(tf("joe"),true) + " head!" ); // prints "There is a fire on her head!"
// 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!"
This method is identical to .yourHisHer(), except that the first letter of the returned string is capitalized.
alert( Util.YourHisHer(tf("joe"),true) + " head is on fire!" ); // prints "His head is on fire!"
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.
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"
This method is identical to .youHeShe(), except that the first letter of the returned string is capitalized.
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"