Jump to content

Ground Decoration has been deprecated...


Recommended Posts

Posted (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 by Noidlox
Posted
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 :)

Posted
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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...