roguehippo Posted May 1, 2016 Posted May 1, 2016 hey there forums, I was just wondering if it would be possible to check the amount of grounditems in a stack. like arrows on the ground. then pick them up if the stack is greater than a number. i tried : GroundItem loot = getGroundItems().closest(g.item); log("test1"); if(loot.getAmount() > 3 && (!inventory.isFull() || inventory.contains(g.item))) { log("test2 in if statement"); loot.interact("Take"); sleep(random(800,1000)); } -------- and the "loot.getamount() > 3" always made my code crash.
Lone Posted May 1, 2016 Posted May 1, 2016 (edited) if(!inventory.isFull()){ if(loot.getAmount() > 3){ loot.interact("Take"); } } Edited May 1, 2016 by Bradf3rd
Solution Posted May 1, 2016 Posted May 1, 2016 what do you mean by null check.That you should nullcheck pretty much everything before interacting with it.If (thing != null) { thing.doSomething; }