This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
smutbook:classes:persistence:persistentobject [2023/08/08 14:36] – lee | smutbook:classes:persistence:persistentobject [2023/08/08 18:39] (current) – lee | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PersistentObject ====== | ====== PersistentObject ====== | ||
- | **Inherits from:** Nothing | + | **Extends:** Nothing |
The PersistentObject is the class from which all of the more complex persistent data types are derived. People, Apparel, Transformable attributes, Inventories of various sorts, and many other classes of objects, are all are ultimately derived from PersistentObject. | The PersistentObject is the class from which all of the more complex persistent data types are derived. People, Apparel, Transformable attributes, Inventories of various sorts, and many other classes of objects, are all are ultimately derived from PersistentObject. | ||
Line 18: | Line 18: | ||
* Don't use strict equality because objects may be reallocated differently between game moments, because of the way SugarCube' | * Don't use strict equality because objects may be reallocated differently between game moments, because of the way SugarCube' | ||
- | ===== Static Properties | + | ===== Static Properties/Functions ===== |
Two static utility functions are defined on PersistentObject. | Two static utility functions are defined on PersistentObject. | ||
Line 61: | Line 61: | ||
- | ===== Constructor ===== | + | ===== Constructor( id ) ===== |
- | // | + | // |
//**You should never instantiate a PersistentObject directly! | //**You should never instantiate a PersistentObject directly! | ||
Line 71: | Line 71: | ||
//**Again, do not ever use " | //**Again, do not ever use " | ||
- | ===== Properties | + | ===== Properties/Functions ===== |
==== .id ==== | ==== .id ==== | ||
This object' | This object' | ||
- | * Type: String | + | |
- | * Automatic | + | |
- | * ReadOnly | + | |
==== .parent ==== | ==== .parent ==== | ||
This object' | This object' | ||
- | * Type: PersistentObject or undefined | + | |
- | * Automatic | + | |
- | * ReadOnly | + | |
==== .name ==== | ==== .name ==== | ||
The display name of the object, without any article. For example: " | The display name of the object, without any article. For example: " | ||
- | * Type: String | + | |
- | | + | |
==== .nameIsProper ==== | ==== .nameIsProper ==== | ||
Set this field to True to suppress the printing of an article in the .aName, .theName, and generic versions of these fields. Useful for proper names, book titles, etc. See the [[Tutorial]] for more information. | Set this field to True to suppress the printing of an article in the .aName, .theName, and generic versions of these fields. Useful for proper names, book titles, etc. See the [[Tutorial]] for more information. | ||
- | * Type: Boolean | + | |
- | | + | |
==== .nameIrregularArticle ==== | ==== .nameIrregularArticle ==== | ||
Set this field to override the default article choice in .aName and generic versions of that field. Setting it back to undefined or null will return things to normal. | Set this field to override the default article choice in .aName and generic versions of that field. Setting it back to undefined or null will return things to normal. | ||
- | * Type: String | + | |
- | | + | |
==== .aName() ==== | ==== .aName() ==== | ||
Line 112: | Line 109: | ||
These rules do not always work. For example, "an honorable man" or "a European swallow" | These rules do not always work. For example, "an honorable man" or "a European swallow" | ||
- | * Type: Function | + | |
- | * Arguments: | + | |
- | | + | |
- | | + | * **Throws:** Nothing |
- | * Returns: String | + | |
- | ==== .AName ==== | + | ==== .AName() ==== |
- | Same as .aName, but with the first character capitalized. | + | Same as .aName(), but with the first character capitalized. |
- | * Type: String (getter) FIXME change to function so it can be overridden in story code more easily. | + | |
- | * Automatic | + | * **Arguments: |
+ | * **Returns: | ||
+ | * **Throws:** Nothing | ||
+ | |||
+ | ==== .theName() ==== | ||
+ | The display name of the object, with the " | ||
+ | |||
+ | These rules do not always work. For example, "the European swallow" | ||
+ | |||
+ | * **Type:** Function | ||
+ | * **Arguments: | ||
+ | * **Returns: | ||
+ | * **Throws:** Nothing | ||
+ | |||
+ | ==== .TheName() ==== | ||
+ | Identical to .theName(), but with the first character capitalized. | ||
+ | |||
+ | * **Type:** Function | ||
+ | * **Arguments: | ||
+ | * **Returns: | ||
+ | * **Throws:** Nothing | ||
==== .genericName === | ==== .genericName === | ||
- | This is the generic non-detailed name of the object, without any article. | + | This is the generic non-detailed name of the object, without any article. |
- | * Type: String | + | |
- | | + | |
==== .genericNameIsProper ==== | ==== .genericNameIsProper ==== | ||
Same as .nameIsProper, | Same as .nameIsProper, | ||
- | * Type: Boolean | + | |
- | | + | |
==== .genericNameIrregularArticle ==== | ==== .genericNameIrregularArticle ==== | ||
Same as .nameIrregularArticle, | Same as .nameIrregularArticle, | ||
- | * Type: String | + | |
- | | + | |
- | ==== .aGenericName ==== | + | ==== .aGenericName() ==== |
- | Same as .aName, but operates on the genericName instead. | + | Same as .aName(), but operates on the genericName instead. |
- | * Type: String | + | |
- | * Automatic | + | * **Arguments: |
+ | * **Returns: | ||
+ | * **Throws:** Nothing | ||
- | ==== .AGenericName ==== | + | ==== .AGenericName() ==== |
- | Same as .AName, but operates on the genericName instead. | + | Same as .AName(), but operates on the genericName instead. |
- | * Type: String | + | |
- | * Automatic | + | * **Arguments: |
+ | * **Returns: | ||
+ | * **Throws:** Nothing | ||
- | ==== .theName | + | ==== .theGenericName() |
- | The display name of the object, with the " | + | Same as .theName(), but operates on the genericName instead. |
- | These rules do not always work. For example, "the European swallow" | + | * **Type:** Function |
+ | * **Arguments: | ||
+ | * **Returns: | ||
+ | * **Throws:** Nothing | ||
- | * Type: String | + | ==== .TheGenericName() ==== |
- | * Automatic | + | Same as .TheName(), but operates on the genericName instead. |
- | ==== .TheName ==== | + | * **Type:** Function |
- | Identical to .theName, but with the first character capitalized. | + | * **Arguments: |
- | + | * **Returns:** String | |
- | | + | * **Throws:** Nothing |
- | * Automatic | + | |
- | + | ||
- | ==== .theGenericName ==== | + | |
- | Same as .theName, but operates on the genericName instead. | + | |
- | + | ||
- | * Type: String | + | |
- | * Automatic | + | |
- | + | ||
- | ==== .TheGenericName ==== | + | |
- | Same as .TheName, but operates on the genericName instead. | + | |
- | + | ||
- | | + | |
- | | + | |
==== .image ==== | ==== .image ==== | ||
- | A detail image name for the object (used in object details displays, and in inventory thumbnails if no thumbnail is defined). | + | A detail image name for the object (used in object details displays, and in inventory thumbnails if no thumbnail is defined. |
- | FIXME Make this work with external images instead of just image passages. | + | * **Type:** String |
- | + | ||
- | | + | |
- | | + | |
==== .thumbnail ==== | ==== .thumbnail ==== | ||
- | A thumbnail image name for the object (used in inventory displays). | + | A thumbnail image name for the object (used in inventory displays). |
- | FIXME Make this work with external images instead of just image passages. | + | * **Type:** Getter returning String |
- | + | ||
- | | + | |
- | | + | |
==== .description ==== | ==== .description ==== | ||
FIXME unimplemented | FIXME unimplemented | ||
- | The name of a passage to display with the detail description of the object. | + | The name of a passage to display with the detail description of the object. |
+ | |||
+ | By default it will use some variant of the object id (FIXME what exactly?), but this can be overridden | ||
* Type: String | * Type: String | ||
Line 221: | Line 224: | ||
==== .toJSON() ==== | ==== .toJSON() ==== | ||
Overridden to provide a reviveWrapper that grabs an instantiated copy of the object via PersistentObject.fetch(). | Overridden to provide a reviveWrapper that grabs an instantiated copy of the object via PersistentObject.fetch(). | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ==== .someProperty ==== | ||
- | Description. | ||
- | |||
- | * **Type:** void | ||
- | * **Automatic** | ||
- | * **ReadOnly** | ||
- | |||
- | ==== .someFunction( arg1, ... ) ==== | ||
- | Description. | ||
- | |||
- | * **Type:** Function | ||
- | * **Arguments: | ||
- | * //arg1//: desc. | ||
- | * //arg2//: desc. | ||
- | * //arg3//: desc. | ||
- | * //arg4//: desc. | ||
- | * //arg5//: desc. | ||
- | * //arg6//: desc. | ||
- | * **Returns: | ||
- | * **Throws:** Nothing. | ||
- | |||
- | Example:< | ||
- | FIXME | ||
- | </ | ||
- | |||
- | |||