Difference between revisions of "AddRequirement"

From King Arthur's Gold Wiki
Jump to: navigation, search
(Created page with "<onlyinclude> Pushes the given requirements to a CBitStream, to be read by other requirement methods. </onlyinclude> This is primarily for use in conjunction with other requ...")
(No difference)

Revision as of 18:55, 18 August 2012

Pushes the given requirements to a CBitStream, to be read by other requirement methods.


This is primarily for use in conjunction with other requirement-handling methods. It will regularly be used with CInventory for checking whether a player has the required materials to do something. In addition, you will use it with things like workshops to set requirements for actions that can be performed at them.

The first parameter is the CBitStream you're adding the requirements to. The requirements string is the type of requirement - the standard ones are "blob", "tech", "coin", "shop" and "time", though you may be able to define your own. The blobName string is the name of the blob that is required, if the requirement is for a kind of blob - leave it blank ("") if it not a kind of blob, for example if it is time. The friendlyName string is what should be displayed to the player as text.

void AddRequirement( CBitStream@ bs, std::string &requirement, std::string &blobName, std::string &friendlyName, u16 &quantity)

Example from Entities/Workshops/Scripts/BankLogic.as:

WorkshopTask @wt = addWorkshopTask( this, "Deposit Money", "$stone_block_1x1$", 0, "genericblock", "Entities/Structures/Stone/Block1x1.cfg" );
AddRequirement( wt.requirements, "coin", "$coin$", "Money", 10 );

Example from Entities/Workshops/Scripts/BankLogic.as:

AddIconMarker( "$Bank$", "Entities/Workshops/Sprites/WorkshopIcons.png", dimension2di(16,16), 5 );
{
  Workshop @w = addWorkshop( this, "Bank", "$Bank$", "Entities/Workshops/Bank.cfg" );
  AddRequirement( w.requirements, "blob", "mat_wood", "Wood", 40 );
  AddRequirement( w.requirements, "blob", "mat_stone", "Stone", 40 );
}