Package parpg :: Package objects :: Module base :: Class Container
[hide private]
[frames] | no frames]

Class Container

source code

object --+        
         |        
BaseObject --+    
             |    
 DynamicObject --+
                 |
object --+       |
         |       |
BaseObject --+   |
             |   |
    Scriptable --+
                 |
                Container

Gives objects the capability to hold other objects

Nested Classes [hide private]
  TooBig
Exception to be raised when the object is too big to fit into container
  SlotBusy
Exception to be raised when the requested slot is occupied
  ItemSelf
Exception to be raised when trying to add the container as an item
Instance Methods [hide private]
 
__init__(self, capacity=0, items=None, **kwargs)
Initialise minimalistic set of data
source code
 
placeItem(self, item, index=None)
Adds the provided carryable item to the inventory.
source code
 
_placeAtVacant(self, item)
Places an item at a vacant slot
source code
 
takeItem(self, item)
Takes the listed item out of the inventory.
source code
 
replaceItem(self, old_item, new_item)
Replaces the old item with the new one
source code
 
removeItem(self, item)
Removes an item from the container, basically the same as 'takeItem' but does run a different script.
source code
 
count(self, item_type="")
Returns the number of items
source code
 
getContentsBulk(self)
Bulk of the container contents
source code
 
getItemAt(self, index) source code
 
indexOf(self, ID)
Returns the index of the item with the passed ID
source code
 
findItemByID(self, ID)
Returns the item with the passed ID
source code
 
findItemByItemType(self, item_type)
Returns the item with the passed item_type
source code
 
findItem(self, **kwargs)
Find an item in container by attributes.
source code
 
serializeItems(self)
Returns the items as a list
source code
 
getStateForSaving(self)
Returns state for saving
source code

Inherited from DynamicObject: __getstate__, __setstate__, prepareStateForSaving, restoreState

Inherited from Scriptable: runScript, setScript

Inherited from BaseObject: trueAttr

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, capacity=0, items=None, **kwargs)
(Constructor)

source code 

Initialise minimalistic set of data

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

placeItem(self, item, index=None)

source code 

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

takeItem(self, item)

source code 

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

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

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

findItem(self, **kwargs)

source code 

Find an item in container by attributes. All params are optional.

Parameters:
  • name (String) - If the name is non-unique, return first matching object
  • kind (String) - One of the possible object types
Returns:
The item matching criteria or None if none was found

getStateForSaving(self)

source code 

Returns state for saving

Overrides: BaseObject.getStateForSaving