Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Get selected item slot


    Soldtodie
     Share

    Recommended Posts

    	public int getSelectedItemSlot() {
    		if(getInventory().isItemSelected()) {
    			for(int slot = 0; slot < 28; slot++) {
    				Item it = getInventory().getItemInSlot(slot);
    				if(it != null && getInventory().getSelectedItemName().contains(it.getName())) {
    					Rectangle is = getInventory().getSlotBounds(slot);
    					for(int x = is.x; x < is.x + is.width; x++) {
    						for(int y = is.y; y < is.y + is.height; y++) {
    							if(getColorPicker().isColor(x, y, new Color(255, 255, 255))) {
    								return slot;
    							}
    						}
    					}
    				}
    			}
    		}
    		return -1;
    	}
    

    The inventory must be open!

    Edited by Soldtodie
    Link to comment
    Share on other sites

    A bit of feedback -> Some items have color 255,255,255 inside them. White partyhat for instance.

     

    You should check if there are > 1 items (of the name selected) in the inventory. If there are, run your computation.

     

    An alternative to this would be to store item slot when selecting an item. Once the menu is no longer use, reset the selected item slot number.

    Link to comment
    Share on other sites

    A bit of feedback -> Some items have color 255,255,255 inside them. White partyhat for instance.

     

    You should check if there are > 1 items (of the name selected) in the inventory. If there are, run your computation.

     

    An alternative to this would be to store item slot when selecting an item. Once the menu is no longer use, reset the selected item slot number.

     

    No you can't find a item with a completely white pixel. The whitest pixel in a white partyhat is 0xFBFBFB

    Link to comment
    Share on other sites

    No you can't find a item with a completely white pixel. The whitest pixel in a white partyhat is 0xFBFBFB

    Oh ok, good find.

     

    To speed up your color searching, you could iterate diagonally (2x1) through the item instead of searching the entire bitmap.

     

    for (int i = 0; i < height; i++) {
      for (int j = 0; j < 2; j++) {
        if (i + j < width) {
          //is it white?
        }
      }
    }
    
    Link to comment
    Share on other sites

    Oh ok, good find.

     

    To speed up your color searching, you could iterate diagonally (2x1) through the item instead of searching the entire bitmap.

     

    for (int i = 0; i < height; i++) {
      for (int j = 0; j < 2; j++) {
        if (i + j < width) {
          //is it white?
        }
      }
    }
    

    u guy have selected item index hooked but it not in api why that?

    it would make this whole method not needed

    Link to comment
    Share on other sites

    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
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.