March 27, 20178 yr So I ran a few scripts that'd get stuck trying to grab arrows from across the fence on the other side which would stop the bot from ignoring the fact that they can't actually reach it cause of clipped fence. Here's a neat snippet for reachable ground item checking. GroundItem groundItems = getGroundItems().closest("Bronze arrows", "Feather"); if (getMap().canReach(groundItems) && groundItems != null) { groundItems.interact("Take"); } The white circle is where arrows would appear from drops from the npcs shown right beside the circle or however they would apparently appear there. Should be pretty self explanatory, or even known. But I haven't personally seen this released or used in the few scripts I ran so eh. For those wonder why I'm collecting arrows, it's to chance collect other players arrow drops, etc.. (just testing purposes right now). Edited March 27, 20178 yr by Booleans YAY
March 27, 20178 yr So your snippet is just the API method: getMap().canReach() ?... I think most people are already aware of the existence of that method Also you probably want to put the null check before the call to canReach() Edited March 27, 20178 yr by Explv
March 27, 20178 yr How is that neat if you null check AFTER using the object? GroundItem groundItems = getGroundItems().closest("Bronze arrows", "Feather"); if (groundItems != null && getMap().canReach(groundItems)) { groundItems.interact("Take"); } If you don't want a shitload of NPE's thrown in your face you should null check BEFORE actually using it ;) Edited March 27, 20178 yr by Khaleesi
March 27, 20178 yr Good job on the contribution, it's nice that somebody is trying to help out; As said above, if you null check after performing an action regarding the item, then it's pretty much redundant, so you should always validate the item first. Though, I don't know why so many are bashing when you're just trying to help.
March 27, 20178 yr At first I thought you were saying there was an error with map.canReach. Then I saw it was a snippet I don't think it's necessary to post snippets of basic API codes. Might as well post snippets on how to open the bank using bank.open();
Create an account or sign in to comment