Jump to content

Interact with Random Item


Skippy joe

Recommended Posts

Hey guys. I've been testing and testing for few hours now. I'm trying to for example out of all the Sharks in my inventory click a random shark. Tried loads of methods. All just seem to click the top shark. Please don't post or ask what this is for or it is not needed. I need someone who could push me in the right direction. Thanks!

Link to comment
Share on other sites

Not the best way to do it, but i wrote it in about 30 seconds...and it should work

 

			int slot = random(0, 27);
			int attempts = 0;
			while (!inventory.getItemInSlot(slot).getName().equals("Shark")) {
				if (attempts > 50)
					break;
				slot = random(0, 27);
				attempts++;
			}
			mouse.click(new InventorySlotDestination(getBot(), slot), false);

Add you own logic, error checking, etc

 

https://osbot.org/api/org/osbot/rs07/input/mouse/InventorySlotDestination.html#InventorySlotDestination-org.osbot.rs07.Bot-int-

Edited by Polymorphism
Link to comment
Share on other sites

Just now, Polymorphism said:

Not the best way to do it, but i wrote it in about 30 seconds...and it should work

 


			int slot = random(0, 27);
			int attempts = 0;
			while (!inventory.getItemInSlot(slot).getName().equals("Shark")) {
				if (attempts > 50)
					break;
				slot = random(0, 27);
				attempts++;
			}
			mouse.click(new InventorySlotDestination(getBot(), slot), false);

 

Thanks a bunch!!! Going to try this soon!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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