crazykid080 14 Share Posted September 30, 2020 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 More sharing options...
Uplift 7 Share Posted September 30, 2020 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 More sharing options...
Hoodz 161 Share Posted September 30, 2020 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 More sharing options...
Aeon 43 Share Posted September 30, 2020 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 More sharing options...
crazykid080 14 Author Share Posted September 30, 2020 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 More sharing options...
crazykid080 14 Author Share Posted September 30, 2020 Looks like Walking#canWalk() was the culprit, I just confirmed it. Thanks everyone Link to comment Share on other sites More sharing options...
Uplift 7 Share Posted September 30, 2020 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 More sharing options...
crazykid080 14 Author Share Posted September 30, 2020 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.