Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • GroundItems.closest not checking tile player is on


    crazykid080

    Recommended Posts

    I've been noticing that closest isn't returning items the tile that the player is on despite it matching the filter I have set.

    For example: I have a filter that allows all items except Bones, ashes, goblin mail, and hammers. My character was standing on a bunch of logs and didn't care about them and went to pick up something else. I do have a validation set of conditions that may be interfering with them so I will include them just in case I did something by mistake

    if (workingArea.contains(item.getTile()) && Walking.canWalk(item.getTile()) && item.isOnScreen()
    	&& Walking.canWalk(item.getTile())) {
    	return true;
    }

     

    Link to comment
    Share on other sites

    1) You have Walking#canWalk() twice in your if statement, won't be causing the issue buy you don't need it twice, save that precious compute resource,

    2) My gut feeling would be that Walking#canWalk must be returning false if you are on the tile -- try getting rid of that and see if it works

    Link to comment
    Share on other sites

    Maybe the model of item is null (because of all the items on the ground), try checking if the item tile is on screen instead of item#isOnScreen

    Link to comment
    Share on other sites

    I think @Hoodz is probably right on this one. For debugging purposes, I'd recommend splitting this if statement into 4 separate if statements and see which one(s) are returning false. This way you can pinpoint exactly where the issue is arising.

    Link to comment
    Share on other sites

    15 hours ago, Uplift said:

    1) You have Walking#canWalk() twice in your if statement, won't be causing the issue buy you don't need it twice, save that precious compute resource

    Thanks for noticing that I just fixed that!

    7 hours ago, Aeon said:

    I think @Hoodz is probably right on this one. For debugging purposes, I'd recommend splitting this if statement into 4 separate if statements and see which one(s) are returning false. This way you can pinpoint exactly where the issue is arising.

    Good idea, I will work on that next

    Link to comment
    Share on other sites

    1 minute ago, crazykid080 said:

    Looks like Walking#canWalk() was the culprit, I just confirmed it. Thanks everyone

    Sweet!

    To troubleshoot issues like that I often will put a println in my script to see the conditions eg,

    System.out.println("Item at: " item.getTile() + " | Working area contains: " + workingArea.contains(item.getTile()) + " | Walking canwalk: " + Walking.canWalk(item.getTile()) + "Item onscreen: " + item.isOnScreen())

    to sanity check logic sometimes

    Link to comment
    Share on other sites

    Oh you can just do getTile for the coords? Well that's helpful to know! I was doing Tile#getX() + ", " + tile#getY()

    Thanks for the input though! I will keep it in mind if I ever run into any issues!

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.