Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question How do you drag items in inventory to a certain spot?

Joined
May 1, 2017
Messages
7
I am creating an high alch bot, but i'm having trouble with finding how you can drag a certain item to a certain spot in your inventory?
 
Joined
Oct 3, 2024
Messages
187
This should be a very good hint :p, tarLocation is the index

Java:
SpriteItem tar = Inventory.getItems(SWAMP_TAR).first();
InteractableRectangle rect = Inventory.getBoundsOf(tarLocation);
Mouse.drag(tar, rect);
 
Misfits
Joined
Nov 21, 2016
Messages
1,568
Code:
 public static void moveItem(String itemName, int indexGoal) {
        SpriteItem item = Inventory.newQuery().names(itemName).results().first();
        if (item != null) {
            if (item.getIndex() != indexGoal) {
                Interactable start = item.getBounds();
                Interactable end = Inventory.getBoundsOf(indexGoal);
                if (start != null && end != null) {
                    log.info("Dragging " + item + " from " + item.getIndex() + " to " + indexGoal);
                    if (Mouse.drag(start, end)) {
                       // delay
                    }
                } else {
                    log.warn("Failed to locate the item or bounds of goal index location");
                }
            }
        }
    }
 
Top