Jump 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.

Opening items in inventory

Featured Replies

I was making a script that at some point needed to open feather packs, but i cant find a way to open them.

if(getInventory().contains(11881)) {

if inventory contains feather pack, open. but how?
}

I checked the api but couldnt find an answer.

if(inventory.contains("Feather pack")){

 inventory.getItem("Feather pack").interact("Open");
  //add conditional sleep

}
  • Author
3 minutes ago, skillerkidos1 said:

if(inventory.contains("Feather pack")){

 inventory.getItem("Feather pack").interact("Open");
  //add conditional sleep

}

Thanks!

On 2/1/2021 at 2:16 AM, skillerkidos1 said:

if(inventory.contains("Feather pack")){

 inventory.getItem("Feather pack").interact("Open");
  //add conditional sleep

}

To improve on this, Item#interact returns a boolean if it was successful or not, so you can do

if(inventory.getItemm("Feath pack").interact("Open")) {
 // Conditional sleep that checks if the number of feather packs in your inventory decreased by 1 
}

 

54 minutes ago, Tom said:

To improve on this, Item#interact returns a boolean if it was successful or not, so you can do



if(inventory.getItemm("Feath pack").interact("Open")) {
 // Conditional sleep that checks if the number of feather packs in your inventory decreased by 1 
}

 

I would say it depends on the situation. In case of feather packs, I can imagine you don't want to wait a tick everytime you open one since opening them as quick as possible is what you essentially want. You would probably need different code to prevent trying to interact with a non-existent item.

Edited by Canidae

I think this is would be better...

        int chain[] ={0,1,2,3,4,5,6,...,28};
        int chain[] ={0,4,8,12,16,20,24,1,5,9,13,17,...};
        for (int i = 0; i < 28; i++) {
            Item item =getInventory().getItemInSlot(chain[i]);
            if (item!=null &&(item.getName().contains("pack"))){
                getInventory().interact(chain[i],"Open");
              	sleep....
            }

        }

 

On 2/1/2021 at 9:05 PM, Nbacon said:

I think this is would be better...


        int chain[] ={0,1,2,3,4,5,6,...,28};
        int chain[] ={0,4,8,12,16,20,24,1,5,9,13,17,...};
        for (int i = 0; i < 28; i++) {
            Item item =getInventory().getItemInSlot(chain[i]);
            if (item!=null &&(item.getName().contains("pack"))){
                getInventory().interact(chain[i],"Open");
              	sleep....
            }

        }

 

This might mess up when trying to pause the script. I would also write it like this:

for (Item item : getInventory().getItems()) {
            if (item != null && item.getName().equals("Feather pack") && item.interact("Open")) {
                //sleep
            }
        }

 

17 hours ago, Canidae said:

This might mess up when trying to pause the script. I would also write it like this:


 

Our loops do the same exact thing and will fuck up in the same way..... but mine can do diffent chaining types...

On 2/4/2021 at 2:57 AM, Nbacon said:

Our loops do the same exact thing and will fuck up in the same way..... but mine can do diffent chaining types...

You forgot to check if the interaction actually was succesful, this way you can trigger the sleep without actually having opened the pack. 

Edited by Canidae

26 minutes ago, Canidae said:

You forgot to check if the interaction actually was succesful, this way you can trigger the sleep without actually having opened the pack. 

Why would you care if the interaction is succesful? you just click and move on and if it fails come back with a second(slower) pass

48 minutes ago, Nbacon said:

Why would you care if the interaction is succesful? you just click and move on and if it fails come back with a second(slower) pass

I agree, I think it's better to not check if interaction is successful. This way, you won't always open items in the perfect order every time.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

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.