GenericMeme46 13 Share Posted August 24, 2019 if (oofer == false) { log("HERE WE GO"); Tile startingTile = getLocalPlayer().getTile(); Tile tile1 = new Tile(startingTile.getX() - 2, startingTile.getY() - 2); Tile tile2 = new Tile(startingTile.getX() - 2, startingTile.getY() + 2); log("TILE1: " + tile1 + " | PLAYER TILE: " + getLocalPlayer().getTile()); getMouse().move(tile1); sleep(5); getMouse().move(tile1); sleep(20); getMouse().click(); getMouse().click(); //Run it twice to guarantee no misclicks scriptBT = System.currentTimeMillis(); oofer = true; } //sleepUntil(() -> getLocalPlayer().getTile() == tile1, 5000); if (getLocalPlayer().getTile() == tile1) { log("TIME IT TOOK REEEE - " + (scriptBT)); } Link to comment Share on other sites More sharing options...
GenericMeme46 13 Author Share Posted August 24, 2019 It never hits true for this part even though the tile1 and player tile absolutely line up with the same values. if (getLocalPlayer().getTile() == tile1) { log("TIME IT TOOK REEEE - " + (scriptBT)); } Link to comment Share on other sites More sharing options...
Empyrean GB 7 Share Posted August 24, 2019 If I were to assume the error here: in java when comparing objects you do not compare the values. You compare the object itself(so or the 2 objects refer to the same place in the ram memory) You are creating a new Tile yourself. this will never refer to the same Tile as the one used in the game context. because you don't compare the x/y values but rather the memory locations. You can either follow my advice in the chat box. Implement a .equals() method to use. or compare the primitive types within the object in the if statement(thus compare the integers associated with the x/y/z levels.) Link to comment Share on other sites More sharing options...
GenericMeme46 13 Author Share Posted August 24, 2019 16 minutes ago, Empyrean GB said: If I were to assume the error here: in java when comparing objects you do not compare the values. You compare the object itself(so or the 2 objects refer to the same place in the ram memory) You are creating a new Tile yourself. this will never refer to the same Tile as the one used in the game context. because you don't compare the x/y values but rather the memory locations. You can either follow my advice in the chat box. Implement a .equals() method to use. or compare the primitive types within the object in the if statement(thus compare the integers associated with the x/y/z levels.) if (getLocalPlayer().getTile().equals(tile1)) { log("TIME IT TOOK REEEE - " + (scriptBT)); } Does not work either. Link to comment Share on other sites More sharing options...
Empyrean GB 7 Share Posted August 24, 2019 What does changing it to: log("Current distance to thile1 " + this.getLocalPlayer().getTile().distance(tile1)); if(this.getLocalPlayer().getTile().distance(tile1) <= 1){ log("TIME IT TOOK REEEE - " + (scriptBT)); } do? Link to comment Share on other sites More sharing options...
GenericMeme46 13 Author Share Posted August 24, 2019 The tiles and their values line up perfectly but it's still refusing to be true Link to comment Share on other sites More sharing options...
Cystic 39 Share Posted August 24, 2019 What if you just try to make it if(tile1.distance(getLocalPlayer()) < 1){ log("TIME IT TOOK REEEE - " + (scriptBT)); } Playing Leauge right now so it may be scuffed Link to comment Share on other sites More sharing options...
GenericMeme46 13 Author Share Posted August 24, 2019 50 minutes ago, Empyrean GB said: What does changing it to: log("Current distance to thile1 " + this.getLocalPlayer().getTile().distance(tile1)); if(this.getLocalPlayer().getTile().distance(tile1) <= 1){ log("TIME IT TOOK REEEE - " + (scriptBT)); } do? This does not work either. if (this.getLocalPlayer().getTile().distance(tile1) < 1) { log("Time - " + (System.currentTimeMillis() - scriptBT + " | Tile " + getLocalPlayer().getTile())); } Link to comment Share on other sites More sharing options...
Cystic 39 Share Posted August 24, 2019 16 minutes ago, GenericMeme46 said: This does not work either. It's not matching your tile1 to your player tile in that example. I don't know exactly what you're trying to do but that's the reason it wouldn't run, you're telling it to run if the tiles are the same but they aren't If you're trying to walk onto a tile and have something happen use something like this. if (oofer == false) { log("HERE WE GO"); Tile startingTile = getLocalPlayer().getTile(); Tile tile1 = new Tile(startingTile.getX() - 2, startingTile.getY() - 2); if(getLocalPlayer().getTile() != tile1) { getWalking().walkExact(tile1); } //Run it twice to guarantee no misclicks scriptBT = System.currentTimeMillis(); oofer = true; } //sleepUntil(() -> getLocalPlayer().getTile() == tile1, 5000); if (getLocalPlayer().getTile() == tile1) { log("TIME IT TOOK REEEE - " + (scriptBT)); } Link to comment Share on other sites More sharing options...
Empyrean GB 7 Share Posted August 24, 2019 1 hour ago, GenericMeme46 said: Interesting negative values in the Current distance tile. Okay, if you change your Tile tile1 = new Tile(startingTile.getX() - 2, startingTile.getY() - 2); to be -5 on both rather then -2. Does it start printing -5, then -4, etc. if so change the if statement to: log("distance to target: " + this.getLocalPlayer().getTile().distance(tile1)); if(Math.abs(this.getLocalPlayer().getTile().distance(tile1)) <= 1){ log("TIME IT TOOK REEEE - " + (scriptBT)); } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.