Jump to content

Item Hovering?


Recommended Posts

Posted (edited)

As part of the Osbot Item API:

public boolean hover()

Description copied from interface: Interactable

Attempts to hover the mouse over the next click needed to interact with this Interactable.
This method will never click the mouse, so it can be used to speed up scripts while they are idling.

Could somebody give me an example of how you would implement this? I am trying to make the script hover the user's mouse over the next log to increase the script's burn speed.

 

This is my current item interaction method.

private boolean interactItems(String itemOne, String itemTwo) throws InterruptedException
{
     if (inventory.getItem(itemOne).interact("use"))
     {
	sleep(random(600,700));
	return inventory.getItem(itemTwo).interact();
     }
     return false;
}

Thanks.

 

Edit: I'm assuming I'll be needing the mouse method so I will change my interact method accordingly.

Edited by steve498
Posted (edited)

Sorry for double post, so just an update, I currently have this:

if(getInventory().contains(itemOne) && getInventory().contains(itemTwo))
    	{
    		// Inventory locations of both items
    		Item firstItem  = getInventory().getItem(itemOne);
    		Item secondItem = getInventory().getItem(itemTwo);
    		
    		// Use items on eachother
    		firstItem.interact("use");
    		sleep(random(300, 430));
    		secondItem.interact();
    		
    		// If a fire is below us then we need drop control of the mouse. Otherwise, a mouse conflict will occur. However, if a fire is not below us then we can pre-hover over the next item.
    		if (IsFireBelowUs() == false) {
    			sleep(random(550, 600));		
	    		firstItem.interact("use");
    		}
    	}

Although this it works fine, half way through an inventory of interacting it will stop pre-hovering on the next item. Any ideas? Thanks

Edited by steve498
Posted (edited)

Yea, your logic is wrong. Try to learn what boolean really is and you should do some null checks (check if item != null etc.).

 

You should also learn how to use dynamic sleep instead of static sleep. How do you know that the script should sleep between 300 and 430 ms. Why 130 ms in difference?

 

For dynamic sleep use api's ConditionalSleep.

Edited by Woody
Posted

Yea, your logic is wrong. Try to learn what boolean really is and you should do some null checks (check if item != null etc.).

 

You should also learn how to use dynamic sleep instead of static sleep. How do you know that the script should sleep between 300 and 430 ms. Why 130 ms in difference?

 

For dynamic sleep use api's ConditionalSleep.

 

Thanks I appreciate the help :)

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