Bryno 21 Posted September 14, 2021 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!
Axolotl 31 Posted September 14, 2021 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; }
Bryno 21 Author Posted September 14, 2021 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();
SubCZ 284 Posted September 14, 2021 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
Bryno 21 Author Posted September 14, 2021 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.
SubCZ 284 Posted September 14, 2021 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
Bryno 21 Author Posted September 14, 2021 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?
Axolotl 31 Posted September 15, 2021 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();
Bryno 21 Author Posted September 15, 2021 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?
Axolotl 31 Posted September 15, 2021 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
Recommended Posts
Archived
This topic is now archived and is closed to further replies.