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 Best way to use Inventory SpriteItem on a GameObjetct?

Joined
Jan 25, 2015
Messages
121
I have a item x in my inventory and I need use it on a object y.

I didn't found a direct method like

Code:
x.useOn(y);

then I tried some stuff (strange...) like

Code:
x.interact("Use");
y.click();

This really didn't worked hahah

So, what a correct way to do this?
 
Java Warlord
Joined
Nov 17, 2014
Messages
4,906
1) Interact with item 1
2) Interact with item 2

Use the development toolkit or similiar to find out the correct actions.
 
Joined
Jan 25, 2015
Messages
121
1) Interact with item 1
2) Interact with item 2

Use the development toolkit or similiar to find out the correct actions.

This has probability to works? While this, let me take a look on dev toolkit.

Code:
x.interact("Use");
//action 0 or ++...
y.interact(y.getDefinition().getActions().get(0));
 
Java Warlord
Joined
Nov 17, 2014
Messages
4,906
This has probability to works? While this, let me take a look on dev toolkit.

Code:
x.interact("Use");
//action 0 or ++...
y.interact(y.getDefinition().getActions().get(0));
Using definitions alone wont work
 
Hexis bots go brrr
Joined
Dec 9, 2016
Messages
4,057
It seems like you've got it figured out. There's no method that using an item on another item/object/npc at the moment. I'll include a snippet from my construction bot which gets the noted planks in the inventory to use on the butler to unnote them.
Code:
SpriteItem notedPlank = Inventory.newQuery().ids(bot.getRequiredNotedID()).results().first();
// The noted id is assigned upon plank selection in GUI

if (notedPlank.click()) {
      if (butler.interact("Use")) {
            getLogger().log("Used planks on butler.");
            bot.setCurrentStatus("Used planks on butler");
      }
}
 
Client Developer
Joined
Oct 12, 2015
Messages
3,760
Interacting with an object whilst you have another selected (for OSRS at least) is

JavaScript:
SpriteItem#interact("Use", selected +  " -> " + target)
 
Primate
Joined
Oct 30, 2014
Messages
3,475
Code:
    default <T1 extends Interactable, T2 extends Interactable> boolean combine(final T1 i1, final T2 i2) {
        final String n1;
        final String n2;
        if ((n1 = getName(i1)) != null && (n2 = getName(i2)) != null) {
            final SpriteItem selected = Inventory.getSelectedItem();
            if (selected != null) {
                if (selected.equals(i1)) {
                    return i2.interact("Use", n1 + " -> " + n2);
                } else if (selected.equals(i2)) {
                    return i1.interact("Use", n2 + " -> " + n1);
                } else {
                    return Interaction.deselectItem() && i1.interact("Use", n1) && i2.interact("Use", n1 + " -> " + n2);
                }
            } else {
                return i1.interact("Use", n1) && i2.interact("Use", n1 + " -> " + n2);
            }
        }
        return false;
    }

Taken from an interface but you should be able to figure out how to get it working.
 
Community Manager
Joined
Apr 7, 2015
Messages
1,394
Code:
    default <T1 extends Interactable, T2 extends Interactable> boolean combine(final T1 i1, final T2 i2) {
        final String n1;
        final String n2;
        if ((n1 = getName(i1)) != null && (n2 = getName(i2)) != null) {
            final SpriteItem selected = Inventory.getSelectedItem();
            if (selected != null) {
                if (selected.equals(i1)) {
                    return i2.interact("Use", n1 + " -> " + n2);
                } else if (selected.equals(i2)) {
                    return i1.interact("Use", n2 + " -> " + n1);
                } else {
                    return Interaction.deselectItem() && i1.interact("Use", n1) && i2.interact("Use", n1 + " -> " + n2);
                }
            } else {
                return i1.interact("Use", n1) && i2.interact("Use", n1 + " -> " + n2);
            }
        }
        return false;
    }

Taken from an interface but you should be able to figure out how to get it working.
OSRS bot devs... Always overcomplicated :kappa:
 
Java Warlord
Joined
Nov 17, 2014
Messages
4,906
Code:
    default <T1 extends Interactable, T2 extends Interactable> boolean combine(final T1 i1, final T2 i2) {
        final String n1;
        final String n2;
        if ((n1 = getName(i1)) != null && (n2 = getName(i2)) != null) {
            final SpriteItem selected = Inventory.getSelectedItem();
            if (selected != null) {
                if (selected.equals(i1)) {
                    return i2.interact("Use", n1 + " -> " + n2);
                } else if (selected.equals(i2)) {
                    return i1.interact("Use", n2 + " -> " + n1);
                } else {
                    return Interaction.deselectItem() && i1.interact("Use", n1) && i2.interact("Use", n1 + " -> " + n2);
                }
            } else {
                return i1.interact("Use", n1) && i2.interact("Use", n1 + " -> " + n2);
            }
        }
        return false;
    }

Taken from an interface but you should be able to figure out how to get it working.
Whats the generics doing there?
 
Top