Jump to content

2 inventory questions. [Solved}


Recommended Posts

Posted
  
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)
Posted
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.

  • Like 1
Posted (edited)

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
Posted
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

Posted (edited)
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
Posted

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. 

Posted (edited)
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

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...