roguehippo Posted May 1, 2016 Share 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. Quote Link to comment Share on other sites More sharing options...
itzDot Posted May 1, 2016 Share Posted May 1, 2016 Null check Quote Link to comment Share on other sites More sharing options...
Lone Posted May 1, 2016 Share Posted May 1, 2016 (edited) if(!inventory.isFull()){ if(loot.getAmount() > 3){ loot.interact("Take"); } } Edited May 1, 2016 by Bradf3rd Quote Link to comment Share on other sites More sharing options...
roguehippo Posted May 1, 2016 Author Share Posted May 1, 2016 what do you mean by null check. Quote Link to comment Share on other sites More sharing options...
MattGP Posted May 1, 2016 Share Posted May 1, 2016 If(loot!=null){ Quote Link to comment Share on other sites More sharing options...
Solution Posted May 1, 2016 Share 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; } Quote Link to comment Share on other sites More sharing options...