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
  • Get selected item slot


    Soldtodie

    Recommended Posts

    Posted
    	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!

    Posted

    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.

    Posted

    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

    Posted

    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?
        }
      }
    }
    
    Posted

    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

    Archived

    This topic is now archived and is closed to further replies.

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