Skip to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

switching case if store contains items

Featured Replies

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;
}

You are trying to pass an array of strings but if you read the api it shows you it expects a single String.

 

75dac7d3c82b351082c92a3111d5523d.png

 

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.

 

75dac7d3c82b351082c92a3111d5523d.png

 

It accepts String... and List<String> as well because Store extends ItemContainer, and those methods can be found in ItemContainer

Edited by Explv

  • Author

You are trying to pass an array of strings but if you read the api it shows you it expects a single String.

 

75dac7d3c82b351082c92a3111d5523d.png

 

 

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;
}

?

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 by House

  • 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)

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.

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

  • 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 by Lewis

 

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 by Explv

  • 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 by Lewis

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. 

  • 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 by Lewis

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.