Welcome!

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

Sign up now!
RuneMate will permanently shut down on August 7, 2026
due to events outside our control. You can continue using RuneMate until this date after which it will no longer be available. Thank you to everyone that contributed to RuneMate's success and to the community for the opportunity to serve you all these years.

  • Learn about RuneMate Vault and how its zero knowledge local encryption already protects your sensitive information.
  • Edit or delete your RuneMate account from your Account Settings.
  • All account upgrade subscriptions have been cancelled. No action required.

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
 
Joined
Dec 9, 2016
Messages
5,776
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,817
Interacting with an object whilst you have another selected (for OSRS at least) is

JavaScript:
SpriteItem#interact("Use", selected +  " -> " + target)
 
Conelander
Joined
Oct 30, 2014
Messages
4,078
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.
 
Joined
Apr 7, 2015
Messages
1,399
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