CInventory::putOutItem

From King Arthur's Gold Wiki
Revision as of 20:46, 19 August 2012 by Shadlington (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Removes the given a CBlob from this inventory, either by CBlob reference or by name.


This method has two variants.

The first variant removes the given CBlob from this inventory, returning true if the CBlob was there to be removed, otherwise returning false.

bool putOutItem(CBlob@ blob)

The second variant looks for a CBlob with the given name in this inventory. The first one it finds with that name will be removed from the inventory and a reference to it will be returned. If it does not find a matching CBlob it will return null.

CBlob@ putOutItem(const string &blobName)

Example from Entities/Common/Scripts/BlobPlacement.as:

void PlaceBlock( CBlob@ this, CBlob @blob, Vec2f cursorPos )
{
  if (this.DetachFrom( blob ))
  {
    blob.setPosition( cursorPos );
    // find an identical one in inventory and put in hands
 
    CBlob @newBlob = this.getInventory().putOutItem( blob.getName() );    if (newBlob !is null)
    {
      // put out of inventory and into hands		
      this.PickupIntoHands( newBlob );
    }
  }
}

Object method of: CInventory