Jump to content

Scripting Help - How to use the Hover method in SDK


Wilmantuxas

Recommended Posts

Hey,

 

I can't seem to get the hang of how to use the `.hover(action)` methods. The way I want to use them is to hover an action on an object and then click it after some condition has been met or after some delay, but if I use the same object for the `.click(action)` method where the action was already hovered, the mouse attempts to right-click the target again. e.g.:

 

Query.gameObjects().findFirst().ifPresent {
    it.hover("Reset")
    Waiting.wait(2000)
    it.click("Reset")
}

 

 

The code above will result in the mouse first hovering the Reset action on an object, and then after two seconds, right-clicking the object again and moving it to the same action, but this time actually clicking it.

 

What am I doing wrong here? How is the hover(action) method supposed to be used? Any help is much appreciated 🙇

 

Edited by Wilmantuxas
Link to comment
Share on other sites

  • Wilmantuxas changed the title to Scripting Help - How to use the Hover method in SDK

This is working just fine for me with a basic Tree - Right-Clicks and hovers over "Examine" for 2 seconds and then clicks it.

Query.gameObjects()
            .nameEquals("Tree")
            .findClosestByPathDistance()
            .ifPresent {
                it.hover("Examine")
                Waiting.wait(2000)
                it.click("Examine")
            }

What object(s) are you having trouble with?

Link to comment
Share on other sites

Virtualy everything. Hover seems to just hover the action but I have no ability to click the action afterwards via the SDK

 

Even with this snippet - it first hovers the 'examine' action and then after the two seconds it right-clicks the object again but this time actually clicks the 'examine'.

 

Added a gif of how it looks for me after running the code here:

 

Query.gameObjects().nameEquals("Loot Chest").findClosestByPathDistance().ifPresent {
    it.hover("Examine")
    Waiting.wait(2000)
    it.click("Examine")
}

 

 

Edited by Wilmantuxas
Link to comment
Share on other sites

You'll probably need to make your own method with ChooseOption. 

Want to view my scripts? Search "Jamie" in the repository!

If you need support, you can join my support discord by clicking the link below or sending me a PM. :)

vDOP8sO.png

Link to comment
Share on other sites

12 hours ago, Jamie said:

You'll probably need to make your own method with ChooseOption. 

How would I go about doing that? Given that the `.click` and `.interact` methods both make the mouse right-click the object again?

AFAIK there's no way of forcing the mouse to click where it's at via the SDK? I know that legacy sdk allows the `Mouse.click(1)` method, but I'd prefer to keep working with the SDK.

 

https://runeautomation.com/docs/sdk/kdocs/-tribot--scripting--s-d-k/org.tribot.script.sdk.input/-mouse/index.html

Link to comment
Share on other sites

You'll need to use Mouse.click

Want to view my scripts? Search "Jamie" in the repository!

If you need support, you can join my support discord by clicking the link below or sending me a PM. :)

vDOP8sO.png

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.

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.

×
×
  • Create New...