This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
smutbook:classes:util:start [2023/08/06 19:58] – created lee | smutbook:classes:util:start [2023/08/06 20:31] (current) – lee | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== 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(). | 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 " | ||
- | |||
- | < | ||
- | // Returns "a two-dollar pistol, a Stetson hat, and a shotgun": | ||
- | [ "a two-dollar pistol", | ||
- | |||
- | // Returns "a two-dollar pistol and a Stetson hat": | ||
- | [ "a two-dollar pistol", | ||
- | |||
- | // Returns "a two-dollar pistol": | ||
- | [ "a two-dollar pistol" | ||
- | |||
- | // Returns " | ||
- | [].commaList() | ||
- | </ | ||
- | |||
- | ==== Array.prototype.aList ==== | ||
- | |||
- | Assuming an array of [[PersistentObject]]s (or subclasses thereof), returns a serial-comma-separated description like .commaList(), | ||
- | < | ||
- | // Assuming pistol, hat, and shotgun are all valid PersistentObjects, | ||
- | // returns "a two-dollar pistol, a Stetson hat, and a shotgun": | ||
- | [ pistol, hat, shotgun ].aList() | ||
- | </ | ||
- | |||
- | ==== Array.prototype.theList ==== | ||
- | |||
- | Assuming an array of [[PersistentObject]]s (or subclasses thereof), returns a serial-comma-separated description like .commaList(), | ||
- | < | ||
- | // Assuming pistol, hat, and shotgun are all valid PersistentObjects, | ||
- | // returns "the two-dollar pistol, the Stetson hat, and the shotgun": | ||
- | [ pistol, hat, shotgun ].theList() | ||
- | </ | ||
- | |||
- | ===== String Prototypes ===== | ||
- | |||
- | ==== String.prototype.capitalize() ==== | ||
- | |||
- | Returns the string with the first character capitalized. | ||
- | |||
- | FIXME: This doesn' | ||
- | |||
- | ===== SmutBook.Util.log( logName, message ) ===== | ||
- | |||
- | If Sugarcube has been put in debug mode (Config.debug=true), | ||
- | |||
- | ===== 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. | ||
- | |||
- | ==== MessageQueue.push( message ) ==== | ||
- | |||
- | If the queue is enabled, push a message into the top of the queue.\\ | ||
- | **Returns: | ||
- | |||
- | ==== MessageQueue.shift() ==== | ||
- | |||
- | If the queue is enabled, shift a message off the bottom of the queue.\\ | ||
- | **Returns: | ||
- | |||
- | ==== MessageQueue.dump( separator=" | ||
- | |||
- | Dump the whole queue as a string, using the given separator. | ||
- | **Returns: | ||
- | |||
- | ==== MessageQueue.on( queue=[] ) ==== | ||
- | |||
- | If the queue is already enabled, to nothing. | ||
- | **Returns: | ||
- | |||
- | ==== MessageQueue.off() ==== | ||
- | |||
- | Disable and clear the queue. | ||
- | **Returns: | ||