PlagueDoctor Posted October 31, 2016 Share Posted October 31, 2016 (edited) Gonna consolidate all of the useful snippets i find or am shown by other users here, so i don't have to mess up my bookmarks. Timer Code: For a timer you could do something like this: //Class variable private long timer; //when you want to start/reset the timer timer = System.currentTimeMillis(); //to check if the timer is past a certain amount of time, ex. 1 min. System.currentTimeMillis() - timer >= 60000; NPC Filtering: NPCs closest returns a single NPC, not a collection of NPCs for you to filter. You want something like: Optional<NPC> suitableNpc = getNpcs().getAll().stream().filter(npc -> npc.getHealthPercent() > 1).findFirst(); if (suitableNpc.isPresent()) { suitableNpc.get().interact("examine"); } You may want to look a little bit into Java 8 streams before using them. Edit:Or better yet you can use the FilterAPI way which is native to OSBot getNpcs().closest(new Filter<NPC>() { @[member='Override'] public boolean match(NPC obj) { return obj.getHealthPercent() > 1; } }) ; EntityAPI: http://osbot.org/api/org/osbot/rs07/api/EntityAPI.html Timer Code #2: http://pastebin.com/W1xcJDwc Lvl 2 Enchant Ring @ Falador East Bank: (wrote this and decided not to use it ) RS2Widget enchant = getWidgets().get(218, 17); Item emeraldRing = getInventory().getItem("Emerald ring"); if(!faladorEastBank.contains(myPlayer())) { status = "Walking to falador east bank."; getWalking().webWalk(faladorEastBank); } if(!getEquipment().isWearingItem(EquipmentSlot.WEAPON, "Staff of air")) { if(!inventory.contains("Staff of air")) { if(!bank.isOpen()) { status = "Opening bank."; getBank().open(); Constants.condSleep(10000, 300, () -> bank.isOpen()); } status = "Withdrawing staff of air."; bank.withdraw("Staff of air", 1); Constants.condSleep(10000, 300, () -> inventory.contains("Staff of air")); } getEquipment().equip(EquipmentSlot.WEAPON,"Staff of air"); status = "Equiping Staff of air."; Constants.condSleep(10000, 300, () -> getEquipment().isWearingItem(EquipmentSlot.WEAPON, "Staff of air")); } if(!getInventory().contains("Emerald ring") || !getInventory().contains("Cosmic rune")) { if(!bank.isOpen()) { status = "Opening bank."; getBank().open(); Constants.condSleep(10000, 300, () -> bank.isOpen()); } status = "Depositing inventory."; getBank().depositAllExcept("Emerald ring", "Cosmic rune"); Constants.condSleep(10000, 300, () -> inventory.onlyContains("Cosmic rune")); status = "Withdrawing cosmics/emerald rings."; bank.withdrawAll("Cosmic rune"); bank.withdrawAll("Emerald ring"); Constants.condSleep(10000, 300, () -> inventory.contains("Emerald ring", "Cosmic rune")); } if(inventory.contains("Emerald ring", "Cosmic rune")) { if(bank.isOpen()) { status = "Closing bank."; bank.close(); } if(!getTabs().open(Tab.MAGIC)) { status = "Opening Magic tab."; getTabs().open(Tab.MAGIC); } if(enchant != null && enchant.isVisible()) { enchant.interact(); status = "Clicking enchant."; if(getTabs().open(Tab.INVENTORY)) { if(emeraldRing != null) { status = "Clicking emerald ring."; emeraldRing.interact(); } Constants.condSleep(10000, 300, () -> getTabs().open(Tab.MAGIC)); } } } Players are nearby: public boolean imAlone() { Area area = alchSpot;//create your own area int amount = 0; for (Player player: players.getAll()) { if (player != null && !player.getName().equalsIgnoreCase(myPlayer().getName())){ if (area.contains(player)) { amount++; } } } return amount == 0; } Edited November 6, 2016 by PlagueDoctor 4 Quote Link to comment Share on other sites More sharing options...
Juggles Posted October 31, 2016 Share Posted October 31, 2016 Good stuff. Quote Link to comment Share on other sites More sharing options...
PlagueDoctor Posted October 31, 2016 Author Share Posted October 31, 2016 Good stuff. Thanks, will be updating and adding stuff here as i find/see it. Quote Link to comment Share on other sites More sharing options...
DrDu Posted January 28, 2017 Share Posted January 28, 2017 looks good fam Quote Link to comment Share on other sites More sharing options...
DrDu Posted February 11, 2017 Share Posted February 11, 2017 any new additions? Quote Link to comment Share on other sites More sharing options...