Jump to content

Ground Decoration has been deprecated...


Guest

Recommended Posts

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
Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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