andrewboss Posted March 19, 2018 Posted March 19, 2018 (edited) Here is the code that I currently use: public boolean isVisible(String name) { return getBank().isSlotVisible(bot, getBank().getSlot(name), getBank().getSlot(name)); } It returns whether the item is visible or not. However, if the item is in the first row, it will always return false. Any ideas what is wrong, or any better implementation for checking? Edited March 19, 2018 by andrewboss
Hannes7337 Posted March 19, 2018 Posted March 19, 2018 I think it has something to do with the absolute slot value. You could only use getbank.getslot(name) instead of getbank.isslotvissible(). If getslot returns null you know it's not there.
andrewboss Posted March 19, 2018 Author Posted March 19, 2018 (edited) 1 hour ago, Hannes7337 said: I think it has something to do with the absolute slot value. You could only use getbank.getslot(name) instead of getbank.isslotvissible(). If getslot returns null you know it's not there. 4 There is no way you could check if it is visible or not by that method. It will always return the slot number if exists, even if not visible. Edited March 19, 2018 by andrewboss
Explv Posted March 19, 2018 Posted March 19, 2018 14 hours ago, andrewboss said: Here is the code that I currently use: public boolean isVisible(String name) { return getBank().isSlotVisible(bot, getBank().getSlot(name), getBank().getSlot(name)); } It returns whether the item is visible or not. However, if the item is in the first row, it will always return false. Any ideas what is wrong, or any better implementation for checking? isSlotVisible takes two different slots as parameters, the tab slot and the absolute slot https://osbot.org/api/org/osbot/rs07/api/Bank.html#isSlotVisible-org.osbot.rs07.Bot-int-int- Right now you are passing absolute slot for both of the parameters, which is incorrect. I don't think there is a public method in the API to get the tab slot, there is a private one though. You can try the following code: public boolean isVisible(int itemID) { return getBank().isSlotVisible(bot, getTabSlot(itemID), getBank().getSlot(itemID)); } private int getTabSlot(final int itemId) { int tabForItem = getBank().getTabForItem(itemId); if (tabForItem == -1) { return -1; } Item[] itemsInTab = getBank().getItemsInTab(tabForItem); for(int i = 0; i < itemsInTab.length; i++) { if(itemsInTab[i] != null && itemsInTab[i].getId() == itemId) { return i; } } return -1; } 1
andrewboss Posted March 19, 2018 Author Posted March 19, 2018 (edited) @Explv Thanks but it still returns false for the first row Edited March 19, 2018 by andrewboss
andrewboss Posted March 19, 2018 Author Posted March 19, 2018 (edited) Figured it out!! If anyone still wants to add his/her own method of doing it, feel free to do so. Edited March 19, 2018 by andrewboss