Jump to content

Drop items?


Recommended Posts

Posted (edited)

Hi, i have a question, i want to drop the items from the inventory avoiding the api path, so i try to make a snake drop path...

Any way, when i try to drop the item from the nº 7 slot, and execute interact, drops me the nº 4.

Is a joke that i'm too peasant to understand??

It's seems like fish (Item var) is linked with nº 7 item, but fish.interact() just jump to 4 and click it.

logs print -> 7 (wich is on a loop until item goes null)

** also i tried getting all the items of the invetory and passing directly nº of the item, but do the same path instead of grabbing item from the getInventory().getItemInSlot().

private void dropFishFromTheInventory(int slotNumberOfTheInventory) throws InterruptedException {
        log(slotNumberOfTheInventory);
        Item fish = getInventory().getItemInSlot(slotNumberOfTheInventory);

        if(fish == null) return;
        if(getSettings().isShiftDropActive()) getKeyboard().pressKey(16);

        for (String fishName :
                SUPPORTED_FISHES) {

            if(fish.getName().contains(fishName)){
                if (getSettings().isShiftDropActive()) {
                    fish.interact();
                } else{
                    fish.interact("drop");
                }

                while(getInventory().getItemInSlot(slotNumberOfTheInventory) != null){
                    waitReflex(1);
                }

                if(getSettings().isShiftDropActive()) getKeyboard().releaseKey(16);
                return;
            }

        }

    }


I'm not sure what i'm doing but i bypassed using:
 

InventorySlotDestination destination = new InventorySlotDestination(getBot(), slotNumberOfTheInventory);
getBot().getEventExecutor().execute(new InteractionEvent(destination, "drop")).hasFinished();

As i'm too noob, I'm not sure if is a bug with Item.Interact(); or is just me xD.

Edited by OsPlay
Posted (edited)

Hello Osplay.

I think your looking for   

 interact(int slot, java.lang.String... actions)

Its under https://osbot.org/api/org/osbot/rs07/api/util/ItemContainer.html

private void dropFishFromTheInventory(int slotNumberOfTheInventory) throws InterruptedException {
        log(slotNumberOfTheInventory);
        Item fish = getInventory().getItemInSlot(slotNumberOfTheInventory);

        if(fish == null) return;
        if(getSettings().isShiftDropActive()) getKeyboard().pressKey(16);

        for (String fishName :
                SUPPORTED_FISHES) {

            if(fish.getName().contains(fishName)){
                if (getSettings().isShiftDropActive()) {
				getInventory().hover(slotNumberOfTheInventory);
                getMouse().click();
                } else{
 				getInventory().	interact(int slotNumberOfTheInventory, "drop")
                 
                }

                while(getInventory().getItemInSlot(slotNumberOfTheInventory) != null){
                    waitReflex(1);
                }

                if(getSettings().isShiftDropActive()) getKeyboard().releaseKey(16);
                return;
            }

        }

    }

 

Edited by Nbacon
  • Like 1
Posted (edited)

@Nbacon yes!!! using both do "snake" pattern with drop!
inventory-Nbacon.gif

Quote

getInventory().hover(slotNumberOfTheInventory);
getMouse().click(false);
or:
InventorySlotDestination destination = new InventorySlotDestination(getBot(), slotNumberOfTheInventory);
getBot().getEventExecutor().execute(new InteractionEvent(destination, "drop"));

 

this is using ItemCollection hover from:

Item fish = getInventory().getItemInSlot(slotNumberOfTheInventory);
Quote

fish.hover();
getMouse().click(false);

inventory-fish-hover.gif

 

or using:

Quote

fish.Interact();


inventory-fish-interact.gif

 

Edited by OsPlay
Posted (edited)

So the bug in those 2 images is fish.Interact()/fish.hover(); will go to the top left most that item [ the reson Item(object) in osbot does not have a slot indicator in it ]

Next thing after you under stand that you see this.

Its spam clicking and there is not wait for them to drop so it "does all the green fish" by clicking  10 times on the frist few fish and then moves on to the pinkish fish.

Edited by Nbacon
  • Like 1
Posted (edited)
2 hours ago, Nbacon said:

[ the reson Item(object) in osbot does not have a slot indicator in it ]

Yep, that was my question/supposition. Thx for anwser!
 

2 hours ago, Nbacon said:

Next thing after you under stand that you see this next thing.

Sry, my english is not strong enought to understand what do you want to say me... 😭
I'm not sure, i just tought that if it happens with interact, it will be all implemented that way, so i just jump to the decompiler, i saw how is executed interact() and try go arround with getEventExecutioner(), i didn't read the api (sry i know, i had to, shame on me), so probably it was a better way to handle, and it was, thx!

 

Quote

Its spam clicking and there is not wait for them to drop so it "does all the green fish" by clicking  9 times on the frist few fish and then moves on to the pinkish fish.

Yep, that is because i removed from the actual code: (human player will not wait until item is dropped for continue)
 

while(getInventory().getItemInSlot(slotNumberOfTheInventory) != null){
  waitReflex(1);
}

but if you add will go: [0][1][2][3][4] and break, instead of [0][1][2][3][7], the ItemContainer on [7], is not null because is in the inventory. (most of the time)
inventory-goes-4.gif

and if the fish in the row nº 7 is different:
inventory-goes-6.gif

this does 1 more because [7] == null, but [6] != null.
inventory-goes-brrrr.gif

Is picking the first Item of the inventory, is not a bug is implemented that way. ❤️

Edited by OsPlay

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