Guest Posted May 28, 2017 Share Posted May 28, 2017 (edited) Okay so this works: RS2Object daisies = objects.closest("Daisies"); if (daisies != null) { log("yeah iz a daiisssyyy"); log("daisy" + daisies.getPosition()); log("mee" + myPlayer().getPosition()); if (daisies.getPosition() == myPlayer().getPosition()) { log("dis works"); } } And this is what I get in the log: [INFO][Bot #1][05/28 08:03:08 PM]: yeah iz a daiisssyyy [INFO][Bot #1][05/28 08:03:08 PM]: daisy[x=3159, y=3261, z=0] [INFO][Bot #1][05/28 08:03:08 PM]: mee[x=3159, y=3261, z=0] However, it doesn't print out "dis works" even though the positions are the same... @Chris @Apaec Edited May 29, 2017 by Noidlox Quote Link to comment Share on other sites More sharing options...
Chris Posted May 29, 2017 Share Posted May 29, 2017 use the .equals() method not == 2 Quote Link to comment Share on other sites More sharing options...
Guest Posted May 29, 2017 Share Posted May 29, 2017 45 minutes ago, Chris said: use the .equals() method not == HOLY SHIT LOL IT WORKED!! And I can see why because we are comparing objects... not variables/numbers @Chris You a legit genius Quote Link to comment Share on other sites More sharing options...
Polymorphism Posted May 29, 2017 Share Posted May 29, 2017 31 minutes ago, Noidlox said: HOLY SHIT LOL IT WORKED!! And I can see why because we are comparing objects... not variables/numbers @Chris You a legit genius It has more to do with comparing primitives vs comparing objects. https://chortle.ccsu.edu/java5/Notes/chap09C/ch09C_2.html Quote Link to comment Share on other sites More sharing options...
Guest Posted May 29, 2017 Share Posted May 29, 2017 24 minutes ago, Polymorphism said: It has more to do with comparing primitives vs comparing objects. https://chortle.ccsu.edu/java5/Notes/chap09C/ch09C_2.html Yeah lol that's what I meant, primitive types. IIRC, you have to use the equals() method with objects because of the way it is stored in memory. It has to do something with the fact that java passes by value, not reference. So when you compare int x and int y, the values are passed but when you compare obj 1 and obj 2, the references in memory are passed...? I think lol... Feel free to correct me if I'm wrong Quote Link to comment Share on other sites More sharing options...