Jump to content

Item Hovering?


steve498

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 :)

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