thiccbooty123 0 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
Pseudo 179 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); }
thiccbooty123 0 Author 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
thiccbooty123 0 Author 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); }
thiccbooty123 0 Author Posted May 25, 2020 7 hours ago, Pseudo said: It's an int bruh, getGroundItemCount(item) > X Gotcha, thanks so much
Recommended Posts
Archived
This topic is now archived and is closed to further replies.