This is an old revision of the document!
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.
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.
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.
This method removes the given item from the inventory.
This method checks to see if the inventory contains the given item.
Check if the inventory is empty.
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.
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.
Overridden
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.
InventoryUI is a static container holding functions to render the inventory UI, as well as the object details UI ().
Given a configuration object, this function renders the inventory UI into a DOM container (which is passed as part of the config object).
This function is called by the InventoryUI macro (see the Macro documentation for more details). You probably don't want to use this function directly unless you are extending LibEcho itself.
The configuration object can contain a number of fields. The values of some of these fields can be a literal or a function. In the case of a function it is called with the listed arguments and the return value is used as the configuration value.
For more information, see the InventoryUI Macro source code.
The parent element to render the UI into.
The GeneralInventory (or subclass) or Person that appears on the left side of the inventory UI. This is conventionally the inventory of the person who is picking things up, or the inventory that things are being picked up and put into, but it can actually be any inventory or person.
The GeneralInventory (or subclass) or Person that appears on the right side of the inventory UI. This is conventionally the inventory from which things are being taken, but it can actually be any inventory or person.
Function to be called when inventory UI is closed. The InventoryUI macro uses this to evaluate the tweecode in the contents of the macro body when the InventoryUI dialog is closed.
If this function returns a String, that value will be printed in place of the “Done” link at the bottom of the inventory modal (preventing the modal from being closed). This can be used to prevent the inventory from being able to be closed until certain items have been taken or dropped, for example. If the return value is a falsy value, the regular “Done” link will be displayed, allowing the modal to be closed.
The Person interacting with the inventory.
The action label for moving item from left inventory.
The left action success word. “ObjectName: dropped.”
The action label for moving item from right inventory.
The left action success word. “ObjectName: taken.”
Called to check if the object will be displayed in left inventory at all.
Called to check if the object will be displayed in right inventory at all.
The item will be shown in the left inventory, but will we show the control to move it to the right inventory?
The item will be shown in the right inventory, but will we show the control to move it to the right inventory?
Return object category for the sort selector.
Will the left selector be shown?
Will the right selector be shown?
Function to call to move item from left to right inventory. If undefined, the built-in implementation will be used.
Function to call to move item from right to left inventory. If undefined, the built-in implementation will be used.
Override the left title.
Override the right title.
Override the left label for item.
Override the right label for item.
Override the builtin outer HTML template.
Override the builtin left list item HTML template.
Override the builtin right list item HTML template.
Override the builtin item details HTML template.