Difference between revisions of "CInventory::hasRequirements"
From King Arthur's Gold Wiki
Shadlington (Talk | contribs) |
Shadlington (Talk | contribs) |
||
Line 29: | Line 29: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
Object method of: [[CInventory]] | Object method of: [[CInventory]] | ||
[[Category:Scripting]] | [[Category:Scripting]] | ||
[[Category:Object Methods]] | [[Category:Object Methods]] |
Latest revision as of 21:11, 19 August 2012
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