November 15, 20169 yr 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; }
November 15, 20169 yr Author 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; }
November 15, 20169 yr You are trying to pass an array of strings but if you read the api it shows you it expects a single String.
November 15, 20169 yr 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, 20169 yr by Explv
November 15, 20169 yr Author 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; } ?
November 15, 20169 yr 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, 20169 yr by House
November 15, 20169 yr Author 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)
November 15, 20169 yr 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.
November 15, 20169 yr 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
November 15, 20169 yr Author 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, 20169 yr by Lewis
November 15, 20169 yr 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, 20169 yr by Explv
November 15, 20169 yr Author 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, 20169 yr by Lewis
November 15, 20169 yr 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.
November 15, 20169 yr Author 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, 20169 yr by Lewis
Create an account or sign in to comment