Echo Hollow

Gender-Bending Interactive Stories! :D

User Tools

Site Tools


smutbook:classes:inventory:generalinventory

This is an old revision of the document!


GeneralInventory

Extends: PersistentObject

DESCRIPTION

Usage Notes

STUFF

Static Properties/Functions

PROBABLY_NONE

Constructor( id )

Do not ever use “new” to instantiate a PersistentObject (or subclass thereof). Instead, store the result of PersistentObject.define() somewhere and reference it when needed, or fetch the object by its 'id' with PersistentObject.fetch().

Properties/Functions

.someProperty

Description.

  • Type: void
  • Automatic
  • ReadOnly

.someProperty

Description.

  • Type: void
  • Automatic
  • ReadOnly

.someProperty

Description.

  • Type: void
  • Automatic
  • ReadOnly

.someProperty

Description.

  • Type: void
  • Automatic
  • ReadOnly

.someProperty

Description.

  • Type: void
  • Automatic
  • ReadOnly

.someProperty

Description.

  • Type: void
  • Automatic
  • ReadOnly

.someProperty

Description.

  • Type: void
  • Automatic
  • ReadOnly

.someProperty

Description.

  • Type: void
  • Automatic
  • ReadOnly

.someProperty

Description.

  • Type: void
  • Automatic
  • ReadOnly

.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: void
  • Throws: Nothing

Example:

FIXME

.someFunction( arg1, ... )

Description.

  • Type: Function
  • Arguments:
    • arg1: desc
    • arg2: desc
    • arg3: desc
    • arg4: desc
    • arg5: desc
    • arg6: desc
  • Returns: void
  • Throws: Nothing

Example:

FIXME

.someFunction( arg1, ... )

Description.

  • Type: Function
  • Arguments:
    • arg1: desc
    • arg2: desc
    • arg3: desc
    • arg4: desc
    • arg5: desc
    • arg6: desc
  • Returns: void
  • Throws: Nothing

Example:

FIXME

.someFunction( arg1, ... )

Description.

  • Type: Function
  • Arguments:
    • arg1: desc
    • arg2: desc
    • arg3: desc
    • arg4: desc
    • arg5: desc
    • arg6: desc
  • Returns: void
  • Throws: Nothing

Example:

FIXME

.someFunction( arg1, ... )

Description.

  • Type: Function
  • Arguments:
    • arg1: desc
    • arg2: desc
    • arg3: desc
    • arg4: desc
    • arg5: desc
    • arg6: desc
  • Returns: void
  • Throws: Nothing

Example:

FIXME

.someFunction( arg1, ... )

Description.

  • Type: Function
  • Arguments:
    • arg1: desc
    • arg2: desc
    • arg3: desc
    • arg4: desc
    • arg5: desc
    • arg6: desc
  • Returns: void
  • Throws: Nothing

Example:

FIXME

.someFunction( arg1, ... )

Description.

  • Type: Function
  • Arguments:
    • arg1: desc
    • arg2: desc
    • arg3: desc
    • arg4: desc
    • arg5: desc
    • arg6: desc
  • Returns: void
  • Throws: Nothing

Example:

FIXME

.someFunction( arg1, ... )

Description.

  • Type: Function
  • Arguments:
    • arg1: desc
    • arg2: desc
    • arg3: desc
    • arg4: desc
    • arg5: desc
    • arg6: desc
  • Returns: void
  • Throws: Nothing

Example:

FIXME

.someFunction( arg1, ... )

Description.

  • Type: Function
  • Arguments:
    • arg1: desc
    • arg2: desc
    • arg3: desc
    • arg4: desc
    • arg5: desc
    • arg6: desc
  • Returns: void
  • Throws: Nothing

Example:

FIXME

.someFunction( arg1, ... )

Description.

  • Type: Function
  • Arguments:
    • arg1: desc
    • arg2: desc
    • arg3: desc
    • arg4: desc
    • arg5: desc
    • arg6: desc
  • Returns: void
  • Throws: Nothing

Example:

FIXME
  • Inherits from: PersistentObject

GeneralInventory is the base Inventory implementation from which all other Inventory types are derived. It provides default functionality which can be overridden in derived classes.

Properties

.contents

An array of the id fields of all the things (PersistentObjects and subclasses) contained in this inventory. Duplicates are not allowed. Order does not matter.

  • Type: Array of strings, or empty array
  • Required

.add( item, actor=null, force=false )

This method adds the given item to the inventory. It does not remove it from any other inventories that might already contain it. You probably usually want to use InventoryUI or .move() instead.

  • item: the thing to be added to the Inventory.
  • actor: the (optional, can be null) Person that is doing the adding.
  • force: if true, the pre- and post- functions will not be called, and item will be added regardless.
  • Returns: true if the item was added or was already in the inventory, or false if the item could not be added to the inventory.
  • Throws: nothing.

.remove( item, actor=null, force=false )

This method removes the given item from the inventory.

  • item: the thing to be removed from the Inventory.
  • actor: the (optional, can be null) Person that is doing the removal.
  • force: if true, the pre- and post- functions will not be called, and item will be removed regardless.
  • Returns: true if the item was removed or was not in the inventory to begin with, or false if the item could not be removed from the inventory.
  • Throws: nothing.

.has( item )

This method checks to see if the inventory contains the given item.

  • item: the thing to be checked for in the Inventory.
  • Returns: true if the inventory contains the specified item, or false if it does not.
  • Throws: nothing.

.isEmpty()

Check if the inventory is empty.

  • Returns: true if the inventory contains no items.
  • Throws: nothing.

.get( filterClass=undefined, filterFunction=undefined )

Returns the fully-instantiated contents of the Inventory.

If a class is passed to filterClass, only items that are of that class (or a subclass thereof) will be included in the returned array.

If a function is passed to filterFunction, that function will be called once for every item in the inventory. If this function returns true, the item will be included in the returned array. If the function returns false, the item will not be included.

  • filterClass: an optional filter class.
  • filterFunction: an optional filter function.
  • Returns: an array containing the fully instantiated contents of the inventory, less those filtered out.
  • Throws: nothing.

.override

When not undefined, the override value sets the value that .toString() returns, ignoring the actual contents (if any) of the inventory.

This is useful for minor characters and objects who do not actually need a fully-featured inventory, as it avoids all the hassle of defining flavor objects to populate the inventory with, that the protagonist will otherwise never be able to interact with. See the Tutorial for details.

  • Type: String
  • Optional

.toString()

Overridden

  • Returns: a serial-comma-separated-list of the inventory's contents' .aName fields.

.theString()

  • Returns: a serial-comma-separated-list of the inventory's contents' .theName fields.

.sort( a, b )

This is the function used by .get() to sort the inventory contents. It follows the rules of Javascript's (Array).sort(). The default implementation sorts alphabetically, ignoring case.

This function is generally only used by derived classes that need to sort the {@link LibEcho.Inventory|Inventory} differently. Unless you are extending the library, you'll probably never need to use it.

  • a: a thing in the inventory.
  • b: another thing in the inventory.
  • Returns: <0 if a<b, >0 if a>b, or 0 if a==b.
smutbook/classes/inventory/generalinventory.1691545157.txt.gz · Last modified: 2023/08/08 18:39 by lee