ff_c_cnd_item
TRUE if the speaking PC carries enough items with each of the given tags.
Stacks are counted by their size, and containers are searched; equipped items
are not counted. With ITEM set to a,b and COUNT set to 1, the PC
must carry at least one a and one b.
Parameters
ITEM: (string) Tag of the item, or a comma-separated list of tags. Required.
COUNT: (int) Number of items required for each tag. Defaults to 1.
Scripts
TextAppearsWhen: ff_c_cnd_item
Source code
// @code
#include "ff_i_core"
// =============================================================================
int StartingConditional()
{
string sItems = GetScriptParam("ITEM");
if (sItems == "")
{
LogError(__FILE__ + ": called with invalid 'ITEM' value");
return FALSE;
}
int nCount = StringToInt(GetScriptParam("COUNT"));
if (nCount < 1)
nCount = 1;
object oPC = GetPCSpeaker();
json jItems = StringSplit(sItems, ",");
int nIndex, nLength = JsonGetLength(jItems);
for (nIndex = 0; nIndex < nLength; nIndex++)
{
string sTag = GetStringTrim(JsonGetString(JsonArrayGet(jItems, nIndex)));
if (sTag != "" && !HasItemFromInventory(oPC, sTag, nCount))
return FALSE;
}
return TRUE;
}