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:41] – 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 70: | Line 70: | ||
//**Again, do not ever use " | //**Again, do not ever use " | ||
- | None. | + | |
- | ===== Properties | + | ===== Properties/Functions ===== |
==== .id ==== | ==== .id ==== | ||
Line 114: | Line 114: | ||
* **Throws:** Nothing | * **Throws:** Nothing | ||
- | Example:< | + | ==== .AName() ==== |
- | FIXME | + | Same as .aName(), but with the first character capitalized. |
- | </ | + | |
- | ==== .AName ==== | + | * **Type:** Function |
- | Same as .aName, but with the first character capitalized. | + | * **Arguments: |
+ | * **Returns: | ||
+ | * **Throws:** Nothing | ||
- | | + | ==== .theName() ==== |
- | * Automatic | + | 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 | ||
+ | |||
+ | * **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 | ||
- | </ | ||
- | |||
- | |||