Jump to content

Drop items?


OsPlay

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

@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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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