thiccbooty123 0 Share Posted May 25, 2020 Hi there, pretty simple thing i need help on. Id like to calculate the items on the floor and inventory combined, and if there is less than a total of 28 then i should drop all eye of newts from my inventory. This is what my boolean looks like: *line* is meant to be the area in which the eye of newts are (the rectangular co-ords of where abouts i would be standing around) private boolean DropEyes() { if (getInventory().contains("Eye of newt") && (getGroundItems(Line).names("Eye of newt").results().size() <= 28)) { status = "Dropping newts"; getInventory().drop("Eye of newt"); } return true; } Thanks so much Link to comment Share on other sites More sharing options...
Pseudo 179 Share Posted May 25, 2020 I'm assuming groundItem.getAmount() doesn't work as they aren't stackable? If so you could iterate of all groundItems in an X tile radius and store the data to a variable? Something like: private int getGroundItemCount(String itemName) { int items = 0; for (GroundItem groundItem : getGroundItems().all(i -> i != null && i.getName().equals(itemName) /*Could additionally check for tile*/)) { if (groundItem != null && groundItem.exists()) { items++; } } return items; } private int getTotalLoadedItemCount(String itemName) { return getInventory().count(itemName) + getGroundItemCount(itemName); } Link to comment Share on other sites More sharing options...
thiccbooty123 0 Author Share Posted May 25, 2020 3 hours ago, Pseudo said: I'm assuming groundItem.getAmount() doesn't work as they aren't stackable? If so you could iterate of all groundItems in an X tile radius and store the data to a variable? Something like: private int getGroundItemCount(String itemName) { int items = 0; for (GroundItem groundItem : getGroundItems().all(i -> i != null && i.getName().equals(itemName) /*Could additionally check for tile*/)) { if (groundItem != null && groundItem.exists()) { items++; } } return items; } private int getTotalLoadedItemCount(String itemName) { return getInventory().count(itemName) + getGroundItemCount(itemName); } Ah fair enough, sorry im quite new to creating scripts Thanks so much, ill let you know how it goes Link to comment Share on other sites More sharing options...
thiccbooty123 0 Author Share Posted May 25, 2020 3 hours ago, Pseudo said: I'm assuming groundItem.getAmount() doesn't work as they aren't stackable? If so you could iterate of all groundItems in an X tile radius and store the data to a variable? Something like: private int getGroundItemCount(String itemName) { int items = 0; for (GroundItem groundItem : getGroundItems().all(i -> i != null && i.getName().equals(itemName) /*Could additionally check for tile*/)) { if (groundItem != null && groundItem.exists()) { items++; } } return items; } private int getTotalLoadedItemCount(String itemName) { return getInventory().count(itemName) + getGroundItemCount(itemName); } Link to comment Share on other sites More sharing options...
thiccbooty123 0 Author Share Posted May 25, 2020 Ignore the above image. Link to comment Share on other sites More sharing options...
Pseudo 179 Share Posted May 25, 2020 It's an int bruh, getGroundItemCount(item) > X Link to comment Share on other sites More sharing options...
thiccbooty123 0 Author Share Posted May 25, 2020 7 hours ago, Pseudo said: It's an int bruh, getGroundItemCount(item) > X Gotcha, thanks so much Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.