CInventory::hasRequirements

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

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

Checks if this inventory contains the given requirements, and writes any missing requirements into a given CBitStream.

Returns true if the requirements are met, otherwise false.


This essentially calls hasRequirements just for this inventory (passing null for the other inventory argument). The requirements parameter is the CBitStream you're reading the requirements from. The missing parameter is a CBitStream that any missing requirements will be written into.

bool hasRequirements(CBitStream@ requirements, CBitStream@ missing)

Example from Entities/Characters/Scripts/BuilderInventory.as:

void onCreateInventoryMenu( CInventory@ this, CBlob@ forBlob, CGridMenu @gridmenu )
{
  CBitStream reqs, missing;
  AddRequirement( reqs, "blob", "mat_stone", "Stones", 10 );
  CGridButton @button = gridmenu.AddButton( "$EmptyShop$", "Make Workshop", Builder::make_workshop );
  if (button !is null)
  {
    if (this.hasRequirements( reqs, missing ))	      SetButtonRequirementsText( button, reqs, false );
    else
      SetButtonRequirementsText( button, missing, true );	
  }
}

Object method of: CInventory