Jump to content

Getting cordinates of inventory items


boyyo11

Recommended Posts

Hey guys, i just got 99 fletch with a bot i made, so now i wanna get my herb up quite a bit so im starting with a herb bot, ive started with just cleaning for now, ill eventually move onto making potions nd what not, but back when I coded for rsbot i made a mouse key herblore cleaner, this one i kinda planned on doing the same.

 

So ive tried doing

for(int i=0;i<27;i++){  //Run throw inventory and click each grimy herb
	inventory.getItemInSlot(i).hover();
	sleep(random(25, 50));
	mouse.click(false);
	sleep(random(25, 50));
}

But with no avail that seems to only just spam click the herb like 4 or 5 times than go onto the next one, so than I moved onto plan 2.

I went and found the interface and child id of the inventory (149, 0) but instead of each slot being a child aswell it seems to be listed as its on detail appon the list when using the interface value debug. So i tried to figure out how I would get the interface for each item slot so I could get the x and y cord and than click in the middle of each slot to simulate mouse keys, and it'd be alot more xp per hr.

 

So how should I go about getting the slot x,y,width, and height? I dont want to have to have an array of integers and what not kinda seems resource wasteful i suppose to say nd kinda hard coded. Any help would be much appricated, thank you so much - boyyo11

Link to comment
Share on other sites

Why don't you use getItem(name). Which return the first item and then interact with it.

 

He's looking for a mouse-keys style of interaction. interact(item) is too slow for him! smile.png

 

 

OP:

 

You can use the following code to generate the area around an item in your inventory (I put this in onpaint just for the visual representation). All you would do then is move the mouse using rectangle destination and click.

Item[] items = this.inventory.getItems();
for (Item item : items) {
Rectangle rectangleAroundItem = this.inventory.getMouseDestination(this.inventory.getSlot(item)).getBoundingBox();
g.drawRect((int) rectangleAroundItem.getX() - 1,
(int) rectangleAroundItem.getY() - 1,
(int) rectangleAroundItem.getWidth() + 1,
(int) rectangleAroundItem.getHeight() + 1);
}

 

 

The rectangle will be recreated every iteration, however if the id/name of the item changes and you adjust the filter for the items array, you should be able to write it like that.

Edited by Apaec
  • Like 1
Link to comment
Share on other sites

 

Cool man works out good, thanks again.

 

Thanks everyone, I ended up doing what dog said, and just did

for(int i=0;i<27;i++){
	mouse.move(inventory.getMouseDestination(i));
	mouse.click(false);
	sleep(random(125, 150));
}

Than made a method to clean rest leftover in inventory. Thanks everyone again, nd ill be releasing my fletcher here within the next two days, im going to make a new GUI for it and add a couple settings so people can run it non stop, its damn near flawless, got me 99 fletching within a week or so

Edited by boyyo11
  • Like 2
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...