This is an old revision of the document!
The PersistentObject is the class from which all of the more complex persistent data types are derived. People, Apparel, Transformable attributes, all are derived from Persistent Object.
Deriving types and classes in this way allows us to present a more straightforward API to the end-user of the library, saving them the headache of dealing directly with the Persistence API.
PersistentObjects use getters and setters to make the complex id-tagged persistence calls look like simple field accesses, to the end-user of the library.
The persistence id of the object.
The persistence id of the object's parent, or null if it doesn't have a parent.
The fully instantiated parent of this object.
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.
var someDude = tfGet("joe"); alert( "someDude's name is " + someDude.name + "." );
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.
alert( "You are carrying " + tfGet("some_item").aName + "." );
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.
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).
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.
tfGet("honorable_man").nameIrregularArticle = "an"; tfGet("european_swallow").nameIrregularArticle = "a";
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.
if( tfGet("joe").hasPersistent("lastName") ) alert( "Joe has a lastName child field!" );
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.
alert( "Joe's last name is " + tfGet("joe").getPersistent("lastName") + "!" );
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.
tfGet("joe").setPersistent( "lastName", "Josephson" );
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.
tfGet("joe").resetPersistent( "lastName" );