Touhou 1 Posted March 5, 2018 Hi everyone ! I'm stuck on something, i'd like to count items on a container. but I'd like to count _x for a group of item. I explaine myself : Every day (ingame) I check with a script if the box "Box" contain a certain amount of items, let's say that I check if there is some food in it. So I'd like to count if there is enough food (like 10 food item) in the box container, but it can be 2 carrots / 1 fish / 4 chickens etc... and I don't want to count like : _nbChicken = {"chicken" == _x} count (itemCargo MyBox); _nbFish = {"Fish" == _x} count (itemCargo MyBox); _nbFood = _nbChicken + _nbFish...... I'd like to make it this way : _table = ["Fish","chicken",etc....]; _nbFood = {_table == _x} count (itemCargo MyBox); is this possible ? Share this post Link to post Share on other sites
HazJ 1289 Posted March 5, 2018 Assuming those are actual items that you or a mod has added then you can do: _table = ["Fish", "chicken", "escargot"]; _nbFood = {_x in _table} count (itemCargo MyBox); Share this post Link to post Share on other sites
Dedmen 2653 Posted March 5, 2018 4 hours ago, HazJ said: Assuming those are actual items that you or a mod has added then you can do: _table = ["Fish", "chicken", "escargot"]; _nbFood = {_x in _table} count (itemCargo MyBox); Keep in mind that that is case sensitive. _table = ["fish", "chicken", "escargot"]; _nbFood = {(toLower _x) in _table} count (itemCargo MyBox); That would be the safe route. 1 Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted March 5, 2018 22 minutes ago, Dedmen said: Keep in mind that that is case sensitive. _table = ["fish", "chicken", "escargot"]; _nbFood = {(toLower _x) in _table} count (itemCargo MyBox); That would be the safe route. This would fail if there's a single upper case typo in one element inside _table in case of user error. To actually be safe do this: _table = ["fish", "chicken", "escargot"] apply {toLower _x}; _nbFood = {(toLower _x) in _table} count (itemCargo MyBox); If you check one element as lowerCase make sure the array you're checking against also only contains lowercase. Cheers 1 Share this post Link to post Share on other sites