Echo Hollow

Gender-Bending Interactive Stories! :D

User Tools

Site Tools


libtf:documentation:api:persistentobject

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
libtf:documentation:api:persistentobject [2018/02/24 19:53] leelibtf:documentation:api:persistentobject [2018/09/24 17:15] (current) – removed lee
Line 1: Line 1:
-[[libtf:documentation:api:start|<-- Back]] 
- 
- 
-====== LibTF.PersistentObject ====== 
- 
-Blurb. 
- 
- 
-===== Fields ===== 
- 
-==== (PersistentObject).id ==== 
- 
-  * Access: Read-Only. 
-  * Type: String. 
- 
-The persistence id of the object. 
- 
- 
-==== (PersistentObject).parentId ==== 
- 
-  * Access: Read-Only. 
-  * Type: String. 
- 
-The persistence id of the object's parent, or null if it doesn't have a parent. 
- 
- 
-==== (PersistentObject).parent ==== 
- 
-  * Access: Read-Only. 
-  * Type: A PersistentObject, or subclass thereof. 
- 
-The fully instantiated parent of this object. 
- 
- 
-==== (PersistentObject).name ==== 
- 
-  * Access: Read-Write. 
-  * Type: String. 
- 
-The display name of the object, without any article.  For example: "Joe", "ancient relic", "pair of gloves" Will be null if the object has no name. 
- 
-<code javascript> 
-var someDude = tfGet("joe"); 
-alert( "someDude's name is " + someDude.name + "." ); 
-</code> 
- 
- 
-==== (PersistentObject).aName ==== 
- 
-  * Access: Read-Only. 
-  * Type: String. 
- 
-The display name of the object, with the correct article prepended.  For example: "Joe", "an ancient relic", "a pair of gloves". 
- 
-If the first character of the //.name// field is capitalized, the name will be treated as proper, and no article will be prepended.  Ie. "Joe". 
- 
-If the first character of the //.name// field is a vowel, the "an" article will be prepended.  Ie. "an ancient relic". 
- 
-Otherwise, the "a" article will be prepended.  Ie. "a pair of gloves". 
- 
-These rules do not always work.  For example, "an honorable man" or "a European swallow" In these cases, the //.nameIsProper// and //.nameIrregularArticle// fields may be used to manually specify the behavior. 
- 
-<code javascript> 
-alert( "You are carrying " + tfGet("some_item").aName + "." ); 
-</code> 
- 
- 
-==== (PersistentObject).nameIsProper ==== 
- 
-  * Access: Read-Write. 
-  * Type: Boolean. 
- 
-Set this field to True to suppress the printing of an article in the //.aName// field.  Useful for names, book titles, etc. 
- 
-//You'll generally want to set this field with Persistence.setDefaults(), and then never touch it again.  The only time you may need to change this field at runtime is if you change something's name to something that doesn't work with the usual rules.// 
- 
-<code javascript> 
-var book = tfGet("atlas_shrugged"); 
-// book.name is "\"Atlas Shrugged\" (a novel by Ayn Rand)" 
-// With the " being the first character, it won't be recognized as proper. 
-// So .aName will return: a "Atlas Shrugged" (a novel by Ayn Rand). 
-book.nameIsProper = true; 
-// Now .aName will properly return just: "Atlas Shrugged" (a novel by Ayn Rand). 
-</code> 
- 
- 
-==== (PersistentObject).nameIrregularArticle ==== 
- 
-  * Access: Read-Write. 
-  * Type: String. 
- 
-Set this field to override the default article choice in //.aName// Setting it back to null will return things back to normal. 
- 
-//You'll generally want to set this field with Persistence.setDefaults(), and then never touch it again.  The only time you may need to change this field at runtime is if you change something's name to something that doesn't work with the usual rules.// 
- 
-<code javascript> 
-tfGet("honorable_man").nameIrregularArticle = "an"; 
-tfGet("european_swallow").nameIrregularArticle = "a"; 
-</code> 
- 
- 
-===== Methods ===== 
- 
-==== (PersistentObject).hasPersistent( subid ) ==== 
- 
-  * //subid// is a persistence id fragment referring to some child data record for this object. 
-  * Returns: (Boolean)  True if there is a record for the specified child data on this object, or False if there is not. 
-  * Throws: Error if: subid contains invalid characters. 
- 
-Checks to see if there is child data for the given //subid// available for this object. 
- 
-//This method is generally only used internally by derived classes.  You probably won't need to use this method unless you are actually extending the library itself.// 
- 
-<code javascript> 
-if( tfGet("joe").hasPersistent("lastName") ) 
- alert( "Joe has a lastName child field!" ); 
-</code> 
- 
- 
-==== (PersistentObject).getPersistent( subid ) ==== 
- 
-  * //subid// is a persistence id fragment referring to some child data record for this object. 
-  * Returns: (Whatever type it was last set to)  The specified child data from this object, or null if there is none. 
-  * Throws: Error if: subid contains invalid characters. 
- 
-Returns the child data for the given //subid// on this object. 
- 
-//This method is generally only used internally by derived classes.  You probably won't need to use this method unless you are actually extending the library itself.// 
- 
-<code javascript> 
-alert( "Joe's last name is " + tfGet("joe").getPersistent("lastName") + "!" ); 
-</code> 
- 
- 
-==== (PersistentObject).setPersistent( subid, value ) ==== 
- 
-  * //subid// is a persistence id fragment referring to some child data record for this object. 
-  * //value// is what to set that child data to. 
-  * Returns: (Whatever type it was last set to)  Nothing, but that is a bug and it ought to return the previous value. 
-  * Throws: Error if: subid contains invalid characters. 
- 
-Sets the child data for the given //subid// on this object to //value//. 
- 
-//This method is generally only used internally by derived classes.  You probably won't need to use this method unless you are actually extending the library itself.// 
- 
-<code javascript> 
-tfGet("joe").setPersistent( "lastName", "Josephson" ); 
-</code> 
- 
- 
-==== (PersistentObject).resetPersistent( subid ) ==== 
- 
-  * //subid// is a persistence id fragment referring to some child data record for this object. 
-  * Returns: (Whatever type it was last set to)  The previous value (before reset). 
-  * Throws: Error if: subid contains invalid characters. 
- 
-Resets the child data for the given //subid// on this object to whatever was defined in Persistence.setDefaults(). 
- 
-//This method is generally only used internally by derived classes.  You probably won't need to use this method unless you are actually extending the library itself.// 
- 
-<code javascript> 
-tfGet("joe").resetPersistent( "lastName" ); 
-</code> 
- 
- 
-[[libtf:documentation:api:start|<-- Back]] 
  
libtf/documentation/api/persistentobject.1519530797.txt.gz · Last modified: 2018/02/24 19:53 by lee