January 14, 20179 yr Tried searching the API/Google for this but no luck. So basically, the script has a list of items to pick up. It checks the loot on the ground against the list of items to pick up and if any match and the inventory is not full, it'll pick it up. What I want to do though, is to pick up a stackable item if my inventory contains a stack already, regardless of if it's full or not. Is there any way to check if an item on the ground is stackable?
January 14, 20179 yr if you already know your inventory is full and the item should be picked up you could try this public boolean isStackable(final String itemName) { return getInventory().contains(itemName) && getInventory().getItem(itemName).getAmount() > 1; } not sure if this is the best way though, i only tested with coins and bones
January 14, 20179 yr Author if you already know your inventory is full and the item should be picked up you could try this public boolean isStackable(final String itemName) { return getInventory().contains(itemName) && getInventory().getItem(itemName).getAmount() > 1; } not sure if this is the best way though, i only tested with coins and bones Thank you! I would have came up with something like that eventually, but I wanted to make sure there wasn't already such a method. Looks like that will have to do. Edit: Just realized a (slight) problem. The method will return false even if an item is stackable but there's only 1 in the inventory. Any ideas to fix this? Edit 2: Actually, I believe this will return true if the inventory contains more of one item, even if it's not in a stack. Edited January 14, 20179 yr by Chromelte
January 14, 20179 yr Thank you! I would have came up with something like that eventually, but I wanted to make sure there wasn't already such a method. Looks like that will have to do. Edit: Just realized a (slight) problem. The method will return false even if an item is stackable but there's only 1 in the inventory. Any ideas to fix this? ooo yeah you're right maybe someone with more experience can help you out Edit 2: Actually, I believe this will return true if the inventory contains more of one item, even if it's not in a stack. tested with 60 coins and 2 bones, should be ok. find a way to fix stackable and 1 in inventory tho Edited January 14, 20179 yr by Stimpack
January 14, 20179 yr you said you had defined a list of items, maybe store a property of that item whether they are stackable or not? or you could check the noted id since a stackable item shouldn't have a noted id. ( i think returns -1 last time i checked). Edited January 14, 20179 yr by Precise
January 14, 20179 yr Author you said you had defined a list of items, maybe store a property of that item whether they are stackable or not? or you could check the noted id since a stackable item shouldn't have a noted id. ( i think returns -1 last time i checked). Thank you! Checking for the noted id worked perfectly!