Lewis Posted November 15, 2016 Share Posted November 15, 2016 practicing with a shop buyer. Looking to hop worlds if store doesnt contain items. i.e final String items[] = new String[] {"Small fishing net", "Harpoon", "Lobster Pot", }; private State getState() { if (!inventory.isFull()) return State.BUY; if (inventory.isFull()) return State.BANK; if (!store.contains(items)) return State.HOP; return State.WAIT; } Quote Link to comment Share on other sites More sharing options...
House Posted November 15, 2016 Share Posted November 15, 2016 http://osbot.org/api/org/osbot/rs07/api/Store.html Quote Link to comment Share on other sites More sharing options...
Lewis Posted November 15, 2016 Author Share Posted November 15, 2016 http://osbot.org/api/org/osbot/rs07/api/Store.html i also tried private State getState() { if (!inventory.isFull()) return State.BUY; if (inventory.isFull()) return State.BANK; if (store.getAmount(items) == 0) return State.HOP; return State.WAIT; } Quote Link to comment Share on other sites More sharing options...
House Posted November 15, 2016 Share Posted November 15, 2016 You are trying to pass an array of strings but if you read the api it shows you it expects a single String. Quote Link to comment Share on other sites More sharing options...
Explv Posted November 15, 2016 Share Posted November 15, 2016 (edited) practicing with a shop buyer. Looking to hop worlds if store doesnt contain items. i.e final String items[] = new String[] {"Small fishing net", "Harpoon", "Lobster Pot", }; private State getState() { if (!inventory.isFull()) return State.BUY; if (inventory.isFull()) return State.BANK; if (!store.contains(items)) return State.HOP; return State.WAIT; } if inventory is full if not in bank walk to bank else if bank is not open open bank else deposit items else if not in store walk to store else if store is not open open store else if store contains items buy items else world hop You are trying to pass an array of strings but if you read the api it shows you it expects a single String. It accepts String... and List<String> as well because Store extends ItemContainer, and those methods can be found in ItemContainer Edited November 15, 2016 by Explv 1 Quote Link to comment Share on other sites More sharing options...
Lewis Posted November 15, 2016 Author Share Posted November 15, 2016 You are trying to pass an array of strings but if you read the api it shows you it expects a single String. so it would look more like: private State getState() { if (!inventory.isFull()) return State.BUY; if (inventory.isFull()) return State.BANK; if (store.getAmount("Pot") == 0 && store.getAmount("Vial of water") == 0) return State.HOP; return State.WAIT; } ? Quote Link to comment Share on other sites More sharing options...
House Posted November 15, 2016 Share Posted November 15, 2016 (edited) so it would look more like: private State getState() { if (!inventory.isFull()) return State.BUY; if (inventory.isFull()) return State.BANK; if (store.getAmount("Pot") == 0 && store.getAmount("Vial of water") == 0) return State.HOP; return State.WAIT; } ? Well does it work? Create a method called isShopEmpty. have a for loop and if any of the items have an amount > 0 return as false; Edited November 15, 2016 by House Quote Link to comment Share on other sites More sharing options...
Lewis Posted November 15, 2016 Author Share Posted November 15, 2016 if inventory is full if not in bank walk to bank else if bank is not open open bank else deposit items else if not in store walk to store else if store is not open open store else if store contains items buy items else world hop It accepts String... and List<String> as well because Store extends ItemContainer, and those methods can be found in ItemContainer ok i see what you done there it will hop if no other statement is true (compared to my wait if no other statement is true) 1 Quote Link to comment Share on other sites More sharing options...
Explv Posted November 15, 2016 Share Posted November 15, 2016 so it would look more like: private State getState() { if (!inventory.isFull()) return State.BUY; if (inventory.isFull()) return State.BANK; if (store.getAmount("Pot") == 0 && store.getAmount("Vial of water") == 0) return State.HOP; return State.WAIT; } ? That logic will not work. Look at your first two conditions. Your inventory is either full, or not full, therefore your script will always be in the BUY or BANK state. Quote Link to comment Share on other sites More sharing options...
Juggles Posted November 15, 2016 Share Posted November 15, 2016 if(getStore().isOpen()) { if(getStore().getAmount(items) <= 0) { return State.HOP; } } That logic will not work. Look at your first two conditions. Your inventory is either full, or not full, therefore your script will always be in the BUY or BANK state. Like he said. It can never reach your hop state because the first or second one are always true Quote Link to comment Share on other sites More sharing options...
Lewis Posted November 15, 2016 Author Share Posted November 15, 2016 (edited) if(getStore().isOpen()) { if(getStore().getAmount(items) <= 0) { return State.HOP; } } Like he said. It can never reach your hop state because the first or second one are always true That logic will not work. Look at your first two conditions. Your inventory is either full, or not full, therefore your script will always be in the BUY or BANK state. Does this look better private State getState() { if (shop.contains(myPlayer())) return State.BUY; if (inventory.isFull()) return State.BANK; if(getStore().isOpen()) { if(getStore().getAmount(items) <= 0) { return State.HOP; } } return State.WAIT; } Edited November 15, 2016 by Lewis Quote Link to comment Share on other sites More sharing options...
Explv Posted November 15, 2016 Share Posted November 15, 2016 (edited) Does this look better private State getState() { if (shop.contains(myPlayer())) return State.BUY; if (inventory.isFull()) return State.BANK; if(getStore().isOpen()) { if(getStore().getAmount(items) <= 0) { return State.HOP; } } return State.WAIT; } Still not right, what if your inventory is full, and you are in the store? Your bot will carry on trying to buy even though it has no space Edited November 15, 2016 by Explv Quote Link to comment Share on other sites More sharing options...
Lewis Posted November 15, 2016 Author Share Posted November 15, 2016 (edited) Still not right, what if your inventory is full, and you are in the store? Your bot will carry on trying to buy even though it has no space Hows this logic looking: private State getState() { if (shop.contains(myPlayer()) && !inventory.isFull()) return State.BUY; if (shop.contains(myPlayer()) && inventory.isFull()) return State.WALK_BANK; if (depositBox.contains(myPlayer()) && inventory.isFull()) return State.BANK; if (!shop.contains(myPlayer()) && !inventory.isFull()) return State.WALK_SHOP; if(getStore().isOpen()) { if(getStore().getAmount(items) <= 0) { return State.HOP; } } return State.WAIT; } Edited November 15, 2016 by Lewis Quote Link to comment Share on other sites More sharing options...
Juggles Posted November 15, 2016 Share Posted November 15, 2016 if (wydinShop.contains(myPlayer()) && inventory.isFull()) return State.WALK_BANK; ^^ This will make your script get stuck. What if your script lags out half way to the bank. Then it's not in the shop anymore and its not in the bank and you're inventory is full. Do if (!Bank.contains(myPlayer) instead of checking if in the shop to start webWalk. Quote Link to comment Share on other sites More sharing options...
Lewis Posted November 15, 2016 Author Share Posted November 15, 2016 (edited) if (wydinShop.contains(myPlayer()) && inventory.isFull()) return State.WALK_BANK; ^^ This will make your script get stuck. What if your script lags out half way to the bank. Then it's not in the shop anymore and its not in the bank and you're inventory is full. Do if (!Bank.contains(myPlayer) instead of checking if in the shop to start webWalk. ohh right, like so private State getState() { if (wydinShop.contains(myPlayer()) && !inventory.isFull()) return State.BUY; if (!depositBox.contains(myPlayer()) && inventory.isFull()) return State.WALK_BANK; if (depositBox.contains(myPlayer()) && inventory.isFull()) return State.BANK; if (!wydinShop.contains(myPlayer()) && !inventory.isFull()) return State.WALK_SHOP; if(getStore().isOpen()) { if(getStore().getAmount(items) <= 0) { return State.HOP; } } return State.WAIT; } Edited November 15, 2016 by Lewis Quote Link to comment Share on other sites More sharing options...