Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Click a Tile (get X and Y)


    Bryno
     Share

    Recommended Posts

    Hi there!

    I see the Tile class has a few methods such as getX() and getY().

    However, I am wanting to prompt the user to "click a tile" and it will save the x and y where they clicked at.

    I'm curious if there is any methods or anything out there to do this?

    Thanks!

    Link to comment
    Share on other sites

    Client.getDestination();
    

    Seems to do the trick, however it returns null when the tile is too close to the current tile of the player.

    If you don't mind that the player has to walk there prior, this'll do:
     

    boolean updatePosition = false;
    
    private Tile getDestination()
    {
        Tile returnTile = null;
        if(getLocalPlayer().isMoving())
            updatePosition = true;
        else
        {
            if(updatePosition)
                returnTile = getLocalPlayer().getTile();
            updatePosition = false;
        }
        return returnTile;
    }
    Link to comment
    Share on other sites

    1 hour ago, Axolotl said:
    Client.getDestination();
    

    Seems to do the trick, however it returns null when the tile is too close to the current tile of the player.

    If you don't mind that the player has to walk there prior, this'll do:
     

    boolean updatePosition = false;
    
    private Tile getDestination()
    {
        Tile returnTile = null;
        if(getLocalPlayer().isMoving())
            updatePosition = true;
        else
        {
            if(updatePosition)
                returnTile = getLocalPlayer().getTile();
            updatePosition = false;
        }
        return returnTile;
    }

    Thanks for your reply!

    However, this will be retrieving the tile the player is currently standing at.

    I am attempting to get a tile that an object (for example, a rock) is at. Therefore, the player will never be able to walk on that tile.

    I would need some sort of method like: Mouse.getClick().getTile();

    Link to comment
    Share on other sites

    6 minutes ago, Bryno said:

    Thanks for your reply!

    However, this will be retrieving the tile the player is currently standing at.

    I am attempting to get a tile that an object (for example, a rock) is at. Therefore, the player will never be able to walk on that tile.

    I would need some sort of method like: Mouse.getClick().getTile();

    Get the polygon of the tile, get a random point in the polygon, move your mouse there

    Link to comment
    Share on other sites

    7 minutes ago, SubCZ said:

    Get the polygon of the tile, get a random point in the polygon, move your mouse there

    Thanks for the reply!

    However, the Tile will be null UNTIL I click the tile.

    I need some listener for the mouseclick and then get the Tile from what the mouse clicked.

    Your suggestion was the opposite process of what I am looking for. 

    Link to comment
    Share on other sites

    5 minutes ago, Bryno said:

    Thanks for the reply!

    However, the Tile will be null UNTIL I click the tile.

    I need some listener for the mouseclick and then get the Tile from what the mouse clicked.

    Your suggestion was the opposite process of what I am looking for. 

    Save mouse coords, click, search tile polygons surrounding your character's walking destination for one that contains your mouse.

    Idk why you'd need that though

    Link to comment
    Share on other sites

    1 minute ago, SubCZ said:

    Save mouse coords, click, search tile polygons surrounding your character's walking destination for one that contains your mouse.

    Idk why you'd need that though

    I am trying to do a "select the rock you want to mine" and it will select that tile.

    So my script will stand between two rocks and powermine them both and not any other rocks nearby.

    Is there a better way of achieving this do you think then?

    Link to comment
    Share on other sites

    3 hours ago, Bryno said:

    I am trying to do a "select the rock you want to mine" and it will select that tile.

    So my script will stand between two rocks and powermine them both and not any other rocks nearby.

    Is there a better way of achieving this do you think then?

    oh I thought it was for walking or something where there is no object on the tile lol. If its just selecting an object under the mouse use:
     

    List<Entity> mouseObjects = Mouse.getEntitiesOnCursor();
    

    then just parse it for w.e names are allowed, if its one of them, save it with:
     

    mouseObjects.get(i).getTile();
    Link to comment
    Share on other sites

    1 hour ago, Axolotl said:

    oh I thought it was for walking or something where there is no object on the tile lol. If its just selecting an object under the mouse use:
     

    List<Entity> mouseObjects = Mouse.getEntitiesOnCursor();
    

    then just parse it for w.e names are allowed, if its one of them, save it with:
     

    mouseObjects.get(i).getTile();

    AWwwhh there we go! That looks like a pretty neat method.

    Is a mining rock classified as an "Entity"

    or will that only pickup things such as NPCs and Mobs?

    Link to comment
    Share on other sites

    1 hour ago, Bryno said:

    AWwwhh there we go! That looks like a pretty neat method.

    Is a mining rock classified as an "Entity"

    or will that only pickup things such as NPCs and Mobs?

    Rocks are classified as 'GameObject', however it will pick it up too, along with NPC/Player and other tile objects. Never personally tested with rocks, but I did with trees and it was added to the list

    Link to comment
    Share on other sites

    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
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.