Echo Hollow

Gender-Bending Interactive Stories! :D

User Tools

Site Tools


smutbook:classes:util

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
smutbook:classes:util [2023/08/06 19:22] leesmutbook:classes:util [2023/08/06 19:58] (current) – removed lee
Line 1: Line 1:
-====== LibEcho.Util ====== 
- 
-Miscellaneous internal utility functions that don't seem to fit anywhere else.  You probably won't ever need to directly use any of these, except maybe String.capitalize(). 
- 
-===== Array Prototypes ===== 
- 
-==== Array.prototype.commaList() ==== 
- 
-Assuming that it is an array of strings, returns a proper serial-comma-separated description of the list including "and", or "nothing" if the list is empty. 
- 
-<code> 
-// Returns "a two-dollar pistol, a Stetson hat, and a shotgun": 
-[ "a two-dollar pistol", "a Stetson hat", "a shotgun" ].commaList()  
- 
-// Returns "a two-dollar pistol and a Stetson hat": 
-[ "a two-dollar pistol", "a Stetson hat" ].commaList() 
- 
-// Returns "a two-dollar pistol": 
-[ "a two-dollar pistol" ].commaList() 
- 
-// Returns "nothing": 
-[].commaList() 
-</code> 
- 
-==== Array.prototype.aList ====  
- 
-Assuming an array of [[persistence|PersistentObjects]] (or subclasses thereof), returns a serial-comma-separated description like .commaList(), but using those objects' .aName fields. 
-<code> 
-// Assuming pistol, hat, and shotgun are all valid PersistentObjects, 
-//  returns "a two-dollar pistol, a Stetson hat, and a shotgun": 
-[ pistol, hat, shotgun ].aList()  
-</code> 
- 
-==== Array.prototype.theList ====  
- 
-Assuming an array of [[persistence|PersistentObjects]] (or subclasses thereof), returns a serial-comma-separated description like .commaList(), but using those objects' .theName fields. 
-<code> 
-// Assuming pistol, hat, and shotgun are all valid PersistentObjects, 
-//  returns "the two-dollar pistol, the Stetson hat, and the shotgun": 
-[ pistol, hat, shotgun ].theList()  
-</code> 
- 
-===== String Prototypes ===== 
- 
-==== String.prototype.capitalize() ==== 
- 
-Returns the string 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? 
- 
-===== SmutBook.Util.log( logName, message ) ===== 
- 
-If Sugarcube has been put in debug mode (Config.debug=true), this function logs the given logName and message to the JS console.  If Sugarcube is not in debug mode, it does nothing. 
- 
-===== LibEcho.Util.MessageQueue ===== 
- 
-A global message queue system to allow the story author to more easily hook into the Inventory and Apparel UIs and display various flavor texts and do other processing while a player is fooling around with Inventory and Apparel. 
- 
-FIXME Not fully implemented.  May change as we rejigger the UIs.  Maybe ought to move from here to the UI classes. 
- 
-==== MessageQueue.push( message ) ==== 
- 
-If the queue is enabled, push a message into the top of the queue.\\ 
-**Returns:** void 
- 
-==== MessageQueue.shift() ==== 
- 
-If the queue is enabled, shift a message off the bottom of the queue.\\ 
-**Returns:** the message being shifted off, or null if the queue is disabled. 
- 
-==== MessageQueue.dump( separator="\n" ) ==== 
- 
-Dump the whole queue as a string, using the given separator.  Clear the queue.\\ 
-**Returns:** the whole queue as a single string 
- 
-==== MessageQueue.on( queue=[] ) ==== 
- 
-If the queue is already enabled, to nothing.  Otherwise enable the queue, filling it with the given array of strings. 
-**Returns:** void 
- 
-==== MessageQueue.off() ==== 
- 
-Disable and clear the queue. 
-**Returns:** the contents of the queue before it was cleared. 
  
smutbook/classes/util.1691374978.txt.gz · Last modified: 2023/08/06 19:22 by lee