This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
libtf:documentation:api:inventory [2018/02/25 11:02] – lee | libtf:documentation:api:inventory [2018/09/24 18:07] (current) – removed lee | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | [[libtf: | ||
- | |||
- | |||
- | ====== LibTF.Inventory====== | ||
- | |||
- | **Inherits From:** [[libtf: | ||
- | |||
- | An Inventory is an object that contains other things. | ||
- | |||
- | |||
- | ===== Fields ===== | ||
- | |||
- | **Inherited from [[libtf: | ||
- | |||
- | |||
- | ===== Methods ===== | ||
- | |||
- | **Inherited from [[libtf: | ||
- | |||
- | |||
- | ==== (Inventory).add( itemOrId ) ==== | ||
- | |||
- | * **Arguments: | ||
- | * **// | ||
- | * **Returns: | ||
- | * **Throws:** Error if: // | ||
- | |||
- | This method adds the given // | ||
- | |||
- | <code javascript> | ||
- | tfGet(" | ||
- | </ | ||
- | |||
- | |||
- | ==== (Inventory).remove( itemOrId ) ==== | ||
- | |||
- | * **Arguments: | ||
- | * **// | ||
- | * **Returns: | ||
- | * **Throws:** Error if: // | ||
- | |||
- | This method removes the given // | ||
- | |||
- | <code javascript> | ||
- | tfGet(" | ||
- | </ | ||
- | |||
- | |||
- | ==== (Inventory).has( itemOrId ) ==== | ||
- | |||
- | * **Arguments: | ||
- | * **// | ||
- | * **Returns: | ||
- | * **Throws:** Error if: // | ||
- | |||
- | This method checks to see if the inventory contains the given // | ||
- | |||
- | <code javascript> | ||
- | if( tfGet(" | ||
- | alert( "Joe has a widget!" | ||
- | </ | ||
- | |||
- | |||
- | ==== (Inventory).get() ==== | ||
- | |||
- | * **Arguments: | ||
- | * **Returns: | ||
- | * **Throws:** Nothing. | ||
- | |||
- | Returns an array of fully instantiated PersistentObjects (or subclasses thereof) contained in the inventory. | ||
- | |||
- | FIXME: We ought to have a method that just returns ids, too... | ||
- | |||
- | <code javascript> | ||
- | alert( "Joe is carrying " + LibTF.Util.commaList(tfGet(" | ||
- | // prints "Joe is carrying a ball of string, an octopus, and a European swallow. | ||
- | </ | ||
- | |||
- | |||
- | ==== (Inventory).someMethod( arg ) ==== | ||
- | |||
- | * **Arguments: | ||
- | * **// | ||
- | * **Returns: | ||
- | * **Throws:** Error if: Stuff. | ||
- | |||
- | Description. | ||
- | |||
- | <code javascript> | ||
- | getListString( examineLink = true ) | ||
- | { | ||
- | let l = []; | ||
- | for( let a of this.get() ) | ||
- | { | ||
- | let examinePassage = " | ||
- | if( examineLink && Story.has(examinePassage) ) | ||
- | l.push( " | ||
- | else | ||
- | l.push( a.aName ); | ||
- | } | ||
- | return Util.commaList( l ); | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | ==== (Inventory).someMethod( arg ) ==== | ||
- | |||
- | * **Arguments: | ||
- | * **// | ||
- | * **Returns: | ||
- | * **Throws:** Error if: Stuff. | ||
- | |||
- | Description. | ||
- | |||
- | <code javascript> | ||
- | sort( a, b ) | ||
- | { | ||
- | return a.name.toLowerCase().localeCompare( b.name.toLowerCase() ); | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | ==== (Inventory).someMethod( arg ) ==== | ||
- | |||
- | * **Arguments: | ||
- | * **// | ||
- | * **Returns: | ||
- | * **Throws:** Error if: Stuff. | ||
- | |||
- | Description. | ||
- | |||
- | <code javascript> | ||
- | preAdd( id ) | ||
- | { | ||
- | return true; | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | ==== (Inventory).someMethod( arg ) ==== | ||
- | |||
- | * **Arguments: | ||
- | * **// | ||
- | * **Returns: | ||
- | * **Throws:** Error if: Stuff. | ||
- | |||
- | Description. | ||
- | |||
- | <code javascript> | ||
- | postAdd( id ) | ||
- | { | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | ==== (Inventory).someMethod( arg ) ==== | ||
- | |||
- | * **Arguments: | ||
- | * **// | ||
- | * **Returns: | ||
- | * **Throws:** Error if: Stuff. | ||
- | |||
- | Description. | ||
- | |||
- | <code javascript> | ||
- | preRemove( id ) | ||
- | { | ||
- | return true; | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | ==== (Inventory).someMethod( arg ) ==== | ||
- | |||
- | * **Arguments: | ||
- | * **// | ||
- | * **Returns: | ||
- | * **Throws:** Error if: Stuff. | ||
- | |||
- | Description. | ||
- | |||
- | <code javascript> | ||
- | postRemove( id ) | ||
- | { | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | [[libtf: | ||