LagunaPreza Posted July 12, 2020 Posted July 12, 2020 Hey all, I recently started with Java coding and I'm fooling around now for my own learning purposes, I'm trying to make an easy Imp killer/looter but the looting part isn't working.. The imps will get killed, however when they drop a bead (either black white yellow or red) it just wont pick it up.. Why ? I have this code in the onLoop: (Yes I know I should probably be using cases) if(!inventory.isFull() && getGroundItems().closest("Black bead", "White bead", "Red bead", "Yellow bead") != null) { getGroundItems().closest("Black bead").interact("Take"); getGroundItems().closest("White bead").interact("Take"); getGroundItems().closest("Red bead").interact("Take"); getGroundItems().closest("Yellow bead").interact("Take"); } else if(!inventory.isFull() && getNpcs().closest("Imp") != null && !myPlayer().isUnderAttack()) { getNpcs().closest("Imp").interact("Attack"); sleep(random(300, 700)); }
Nbacon Posted July 12, 2020 Posted July 12, 2020 (edited) This is a code from my scheme bot . arr= {"Black bead", "White bead", "Red bead", "Yellow bead"} GroundItem ff = Scheme.scemeBot.getGroundItems().closest(arr); int emptySlots = Scheme.scemeBot.getInventory().getEmptySlots(); if (ff!=null&&ff.interact("Take")) { Sleep.sleepUntil(() -> { return Scheme.scemeBot.getInventory().getEmptySlots() < emptySlots || Scheme.scemeBot.getGroundItems().closest(arr) == null; }, 5000); } P.S. You should always null check Things that return objects getNpcs().closest() Look in to condition sleeps Edited July 12, 2020 by Nbacon