Right now we are only having the predicate of if the specific item is in the Inventory. But what if we want to have a stackable item like for example chickens and want to check if we have 20 of those chickens (with the same ID to have them stackable) in the Inventory?
case "HasInventoryItem":
return HasItem(InventoryItem.GetFromID(parameters[0]));
that’s what we have right now. But we somehow need to get the GetNumberInSlot function right? or is there a simple and easy solution for that?
case EPredicate.HasItems: //Only works for stackable items.
InventoryItem item = InventoryItem.GetFromID(parameters[0]);
int stack = FindStack(item);
if (stack == -1) return false;
if (int.TryParse(parameters[1], out int result))
{
return slots[stack].number >= result;
}
return false;
LOL, oops, you don’t, unless you’re using my improved Condition property editor: Improving Conditions: A Property Editor
Just replace that with your string parameter, looks like in your case “HasInventoryItems”
switch (predicate)
{
case "HasInventoryItem":
return HasItem(InventoryItem.GetFromID(parameters[0]));
case "HasInventoryItems":
InventoryItem item = InventoryItem.GetFromID(parameters[0]);
int stack = FindStack(item);
if (stack == -1) return false;
if (int.TryParse(parameters[1], out int result))
{
return slots[stack].number >= result;
}
return false;
}
return null;
But how do I set this up in the Dialogue right now? With HasInventoryItem and the right ID I can ask for the right Item but how do I make this correspond with the amount? Like I need to somewhere writte the amount of this specific item that should be In the Inventory right? Or do I simply need to make another AND statement and put in HasInventoryItems and instead of the ID the amount?
So I put in the itemID and a quantity of 3 but he is doing nothing. Even if I picked up 3 of the asked items. Am I so stupid and doing something super wrong here?
I see there is a second element to the And, but it’s collapsed, so I have no idea what it is. For testing, try it with only the HasInventoryItems predicate.