Package scripts :: Script inventory :: Class Inventory
[hide private]
[frames] | no frames]

Class Inventory

source code

             object --+            
                      |            
objects.base.BaseObject --+        
                          |        
 objects.base.DynamicObject --+    
                              |    
             object --+       |    
                      |       |    
objects.base.BaseObject --+   |    
                          |   |    
    objects.base.Scriptable --+    
                              |    
         objects.base.Container --+
                                  |
                                 Inventory

The class to represent inventory 'model': allow operations with inventory contents, perform weight/bulk calculations, etc

Nested Classes [hide private]

Inherited from objects.base.Container: ItemSelf, SlotBusy, TooBig

Instance Methods [hide private]
 
__init__(self, **kwargs)
Initialise instance
source code
 
onChildPlaceItem(self, container) source code
 
placeItem(self, item, index=None)
Adds the provided carryable item to the inventory.
source code
 
takeItem(self, item)
Takes the listed item out of the inventory.
source code
 
removeItem(self, item)
Removes an item from the container, basically the same as 'takeItem' but does run a different script.
source code
 
replaceItem(self, old_item, new_item)
Replaces the old item with the new one
source code
 
getWeight(self)
Total weight of all items in container + container's own weight
source code
 
setWeightDummy(self, weight) source code
 
count(self, item_type="")
Returns the number of items
source code
 
takeOff(self, item) source code
 
moveItemToSlot(self, item, slot, index=None) source code
 
getItemsInSlot(self, slot, index=None) source code
 
isSlotEmpty(self, slot, index=None) source code
 
has(self, item_ID) source code
 
findItemByID(self, ID)
Returns the item with the passed ID
source code
 
findItem(self, **kwargs)
Find an item in inventory by various attributes.
source code
 
__repr__(self)
repr(x)
source code
 
serializeInventory(self)
Returns the inventory items as a list
source code
 
getStateForSaving(self)
Returns state for saving
source code

Inherited from objects.base.Container: findItemByItemType, getContentsBulk, getItemAt, indexOf, serializeItems

Inherited from objects.base.Container (private): _placeAtVacant

Inherited from objects.base.DynamicObject: __getstate__, __setstate__, prepareStateForSaving, restoreState

Inherited from objects.base.Scriptable: runScript, setScript

Inherited from objects.base.BaseObject: trueAttr

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  weight = property(getWeight, setWeightDummy, "Total weight of ...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **kwargs)
(Constructor)

source code 

Initialise instance

Parameters:
  • name - Object display name
  • name - Filename of image to use in inventory
Overrides: object.__init__

placeItem(self, item, index=None)

source code 

Adds the provided carryable item to the inventory. Runs an 'onStoreItem' script, if present

Overrides: objects.base.Container.placeItem
(inherited documentation)

takeItem(self, item)

source code 

Takes the listed item out of the inventory. Runs an 'onTakeItem' script

Overrides: objects.base.Container.takeItem
(inherited documentation)

removeItem(self, item)

source code 

Removes an item from the container, basically the same as 'takeItem' but does run a different script. This should be used when an item is destroyed rather than moved out. Runs 'onRemoveItem' script

Overrides: objects.base.Container.removeItem
(inherited documentation)

replaceItem(self, old_item, new_item)

source code 

Replaces the old item with the new one

Parameters:
  • old_item (Carryable) - Old item which is removed
  • new_item (Carryable) - New item which is added
Overrides: objects.base.Container.replaceItem

count(self, item_type="")

source code 

Returns the number of items

Overrides: objects.base.Container.count
(inherited documentation)

findItemByID(self, ID)

source code 

Returns the item with the passed ID

Overrides: objects.base.Container.findItemByID
(inherited documentation)

findItem(self, **kwargs)

source code 

Find an item in inventory by various attributes. All parameters are optional.

Parameters:
  • name (String) - Object name. If the name is non-unique, first matching object is returned
  • kind (String) - One of the possible object kinds like "openable" or "weapon" (see base.py)
Returns:
The item matching criteria or None if none was found
Overrides: objects.base.Container.findItem

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

getStateForSaving(self)

source code 

Returns state for saving

Overrides: objects.base.BaseObject.getStateForSaving

Class Variable Details [hide private]

weight

Value:
property(getWeight, setWeightDummy, "Total weight of container")