Jump to content

Use an item in specific slot help


Recommended Posts

Posted (edited)

Hey, is there a way to select an item in a specific slot in the inventory? I am using :

sA.inventory.getItemInSlot(14).interact("Use");

to select the 14th unstrung bow, however it just selects the first one (which I understand why). Is there a way to do it without manually defining the area on the screen to click? 

http://osbot.org/api/org/osbot/rs07/api/Inventory.html

 

the Inventory subclass doesn't override the ItemContainer's "getItemInSlot" abstract method, meaning it's always gonna use the same method definedd in the parent class

Edited by senpai jinkusu
Posted

getItemInSlot simply returns an Item instance. Item does not contain any information about which slot it was retrieved from. So when you try to interact with that item, it will simply use the first one it finds.

 

What you need to use is the overload of interact that takes a slot id as parameter

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

eg.

getInventory().interact(14, "Use");

  • Like 1

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