harrypotter Posted March 30, 2017 Posted March 30, 2017 I know the API has: inventory.contains(); However this will return true as long as 1 item from the selected exists. I want to confirm that the inventory contains all of the items however. What's the best way to do this rather than a statement for each item? Thanks for your help!
Polymorphism Posted March 30, 2017 Posted March 30, 2017 You could do something like String[] ITEMS = .... for(String item : ITEMS) if(!inventory.contains(item)) return false return true; 3
Stimpack Posted March 30, 2017 Posted March 30, 2017 (edited) https://osbot.org/api/org/osbot/rs07/api/util/ItemContainer.html#onlyContains-org.osbot.rs07.api.filter.Filter...- https://osbot.org/api/org/osbot/rs07/api/util/ItemContainer.html#onlyContains-int...- https://osbot.org/api/org/osbot/rs07/api/util/ItemContainer.html#onlyContains-java.lang.String...- edit: yeah confirmed by @Diclonius, above is not what you're looking for :c Edited March 30, 2017 by Stimpack
Polymorphism Posted March 30, 2017 Posted March 30, 2017 2 minutes ago, Stimpack said: https://osbot.org/api/org/osbot/rs07/api/util/ItemContainer.html#onlyContains-org.osbot.rs07.api.filter.Filter...- Not even close.
Diclonius Posted March 30, 2017 Posted March 30, 2017 1 minute ago, Stimpack said: https://osbot.org/api/org/osbot/rs07/api/util/ItemContainer.html#onlyContains-org.osbot.rs07.api.filter.Filter...- I believe he's asking for a method for checking if the inventory contains all items, and possibly any others. This methods checks if the inventory contains all the items and no others.
Stimpack Posted March 30, 2017 Posted March 30, 2017 2 minutes ago, Diclonius said: I believe he's asking for a method for checking if the inventory contains all items, and possibly any others. This methods checks if the inventory contains all the items and no others. yeah i just noticed!
Booleans YAY Posted April 2, 2017 Posted April 2, 2017 On 3/30/2017 at 10:09 AM, Polymorphism said: You could do something like String[] ITEMS = .... for(String item : ITEMS) if(!inventory.contains(item)) return false return true; No need for external object to store data simply call as the following instead, you also can call Strings instead as well rather than pull the ids. if (getInventory().contains(1042, 1050, 11694)) { // do stuff }
Reveance Posted April 2, 2017 Posted April 2, 2017 (edited) 14 hours ago, Booleans YAY said: No need for external object to store data simply call as the following instead, you also can call Strings instead as well rather than pull the ids. if (getInventory().contains(1042, 1050, 11694)) { // do stuff } Read the OP, this is not the same behaviour as the code the post you quoted contains. And the OP literally said the method you posted doesn't do what he needs. Edited April 2, 2017 by Reveance 1