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.

2 inventory questions. [Solved}

Featured Replies

How would I go about swapping items and how could I make the script interact with two inventory slots?

Help is much appreciated!
Thanks!

Edited by Vurqol
Solved

  
getInventory().interact(getInventory().getSlotForNameThatContains(Item1Name), "Use");

getInventory().interact(28, "Use"); // Slotid = 11

if (getInventory().contains(item1Name) && getInventory().contains(item2Name)) {
					getInventory().getItem(item1Name).interact("Use");
					sleep(250); // slight delay to allow the script to select it, should be a conditional for "lagg" etc. 
					getInventory().getItem(item2Name).interact("Use");

 

3 options above.

Now if you want to drag the item and switch it with something else you're going to need to use the 

continualClick(MouseDestination destination, org.osbot.rs07.utility.Condition condition)
30 minutes ago, Durky said:

  
getInventory().interact(getInventory().getSlotForNameThatContains(Item1Name), "Use");

getInventory().interact(28, "Use"); // Slotid = 11

if (getInventory().contains(item1Name) && getInventory().contains(item2Name)) {
					getInventory().getItem(item1Name).interact("Use");
					sleep(250); // slight delay to allow the script to select it, should be a conditional for "lagg" etc. 
					getInventory().getItem(item2Name).interact("Use");

 

3 options above.

Now if you want to drag the item and switch it with something else you're going to need to use the 


continualClick(MouseDestination destination, org.osbot.rs07.utility.Condition condition)

Please perform checks on your methods:

if (getInventory().contains(ITEM1) && getInventory().contains(ITEM2)) {
    if (!getInventory().isItemSelected()) {
     	// Select Item then sleep until an item is selected
    } else {
     	// Use Items together then sleep until no item is selected
    }
}

I just wrote this up so I haven't tested this or verified that the method names are correct but you should get the gist.

  • Author

I'm currently trying something like this
 

getInventory().interact(23);
log("Slot 23 Selected");
new ConditionalSleep(1500) {
    @Override
    public boolean condition() throws InterruptedException {
        return inventory.isItemSelected();
    }
}.sleep();
getInventory().interact(28);
log("Slot 28 Selected");
new ConditionalSleep(1500) {
    @Override
    public boolean condition() throws InterruptedException {
        return !inventory.contains("");

 

And while I have gone ahead and tried "Use" on both interacts. It's only interacting with one of them and rolling through it saying that it has executed the other but only doing the first,

The code works when I use another interact but instead I don't use the second slot. Making what I'm after just a little bit inefficient :/

Note, both slots only require a left click

**edit I have taken another look at the API and noticed that there's a few "interacts with first item matched" Is there a "last item matched" ?

Edited by Vurqol

12 hours ago, Ragnar Lothbrok said:

Please perform checks on your methods:


if (getInventory().contains(ITEM1) && getInventory().contains(ITEM2)) {
    if (!getInventory().isItemSelected()) {
     	// Select Item then sleep until an item is selected
    } else {
     	// Use Items together then sleep until no item is selected
    }
}

I just wrote this up so I haven't tested this or verified that the method names are correct but you should get the gist.

i wasn't writing it for him, also the comments clearly state you should be using a conditional sleep, inwhich you should be delaying until item1 is selected. Thanks thou

2 hours ago, Vurqol said:

I'm currently trying something like this
 


getInventory().interact(23);
log("Slot 23 Selected");
new ConditionalSleep(1500) {
    @Override
    public boolean condition() throws InterruptedException {
        return inventory.isItemSelected();
    }
}.sleep();
getInventory().interact(28);
log("Slot 28 Selected");
new ConditionalSleep(1500) {
    @Override
    public boolean condition() throws InterruptedException {
        return !inventory.contains("");

 

And while I have gone ahead and tried "Use" on both interacts. It's only interacting with one of them and rolling through it saying that it has executed the other but only doing the first,

The code works when I use another interact but instead I don't use the second slot. Making what I'm after just a little bit inefficient :/

Note, both slots only require a left click

**edit I have taken another look at the API and noticed that there's a few "interacts with first item matched" Is there a "last item matched" ?

i'm kind of confused, could you maybe try to explain it a different way?

 

 

**note sorry for the multi post, multi quote wasn't functioning properly for me. :(

 

Edited by Durky

  • Author

So I'm trying to use a specific inventory slot on another specific inventory slot.

However there are 14 of each of the item in the inventory. There is simply no interface to "Make all"

So having the items next too each other in the inventory and then having the script execute it so the slots are used on each other is better
Or else it's just using slot 1 and slot 15. which is half the inventory away.

These items also move around and it's more effective too have the item in the bottom two slots as you can spam it and make two in a tick if done correctly, this cannot be achieved if they are half an inventory away and such it's inefficient. 

  • Author

Still looking for help if anyone can  :)

Edited by Vurqol

  • Author

@Durky
Fixed it...
I was going off the basis that slot 28 in the inventory is 28.

However Java starts at 0.
Making it 27.

On 1/30/2019 at 1:22 AM, Vurqol said:

 


getInventory().interact(23);
log("Slot 23 Selected");
new ConditionalSleep(1500) {
    @Override
    public boolean condition() throws InterruptedException {
        return inventory.isItemSelected();
    }
}.sleep();
getInventory().interact(28);
log("Slot 28 Selected");
new ConditionalSleep(1500) {
    @Override
    public boolean condition() throws InterruptedException {
        return !inventory.contains("");

You should really not do conditional sleeps like that, since the interact function will not go on before it returns either a fail or a success. Since the sleeps will just pass instant if the interact was a success and if the interact was a failure then they will just delay your script for 1500 ms and then continue, even though it failed. Which is not good...

Do if statements instead (like Ragnar Lothbrok said), this way you can break out of the loop or start over if it fails instead of just delaying it and expecting it to always work, example:

if (getInventory().interact(23)) {
	log("Slot 23 Selected"); // Continue it worked!
} else {
	log("Failed to select slot 23!"); // We failed lets break out of the loop and try again!
	return;
}

Do this for both slots and then you can do an conditional sleep statement in the end to check if the inventory contains the item or not to see if the whole interaction went well or not. This is just to wait for the animation to finish up since the interact will fishish first.

You should always consider why you would need a sleep at all, so you don't end up using them wrong! Since you wont be waiting for the interact function it already pauses and won't continue before it returns a fail or success. But you would like to do a sleep when you have preformed the action because the game does an animation(delay) before the action happens and the items are combined or changed.

Edited by ItPoke

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.