Acerd Posted July 17, 2016 Share Posted July 17, 2016 (edited) 1-7 makes gloves 7-9 makes boots 9-10 makes cowls requested by: http://osbot.org/forum/topic/102807-crafting-till-level-10-script-request/?view=getnewpost link: http://uppit.com/abbhqeuf9nu8 source: import java.util.Optional; import java.util.function.BooleanSupplier; import org.osbot.rs07.api.Widgets; import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.MethodProvider; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(author = "Acerd", info = "", logo = "", name = "1-10 crafting", version = 0) public class TenCrafting extends Script { private CachedWidget widget; private Armour armour; private boolean started; @Override public void onStart() throws InterruptedException { super.onStart(); started = true; } @SuppressWarnings("unchecked") @Override public int onLoop() throws InterruptedException { if (started) { if (getSkills().getStatic(Skill.CRAFTING) < 7) armour = Armour.LEATHER_GLOVES; else if (getSkills().getStatic(Skill.CRAFTING) < 9) armour = Armour.LEATHER_BOOTS; else armour = Armour.LEATHER_COWL; widget = new CachedWidget(armour.getArmour()); if (getSkills().getStatic(Skill.CRAFTING) >= 10) { stop(); } else if (canCraftArmour()) { if (isAmountPromptVisible()) { if (getKeyboard().typeString("" + MethodProvider.random(27, 99), true)) { new CSleep(() -> !canCraftArmour() || mustContinue(), 100_000).sleep(); } } else if (widget.getWidget(getWidgets()) != null) { if (widget.getWidget(getWidgets()).interact(armour.getOption())) { new CSleep(() -> !canCraftArmour() || mustContinue() || isAmountPromptVisible(), 100_000) .sleep(); } } else if (!isItemSelected("Needle")) { getInventory().interact("Use", "Needle"); } else { if (getInventory().interact("Use", "Leather")) { new CSleep(() -> widget.getWidget(getWidgets()) != null, 5_000).sleep(); } } } else { if (!getBank().isOpen()) openBank(); else if (getInventory().contains(i -> !i.getName().equals("Needle") && !i.getName().equals("Thread") && !i.getName().equals("Leather"))) { getBank().depositAllExcept("Needle", "Thread", "Leather"); } else if (!getInventory().contains("Needle")) { if (getBank().contains("Needle")) { getBank().withdraw("Needle", 1); } else { stop(); } } else if (!getInventory().contains("Thread")) { if (getBank().contains("Thread")) { getBank().withdrawAllButOne("Thread"); } else { stop(); } } else if (!getInventory().contains("Leather")) { if (getBank().contains("Leather")) { getBank().withdrawAll("Leather"); } else { stop(); } } else { getBank().close(); } } } return 300; } private final class CSleep extends ConditionalSleep { private final BooleanSupplier condition; public CSleep(final BooleanSupplier condition, int timeout) { super(timeout); this.condition = condition; } @Override public boolean condition() throws InterruptedException { return condition.getAsBoolean(); } } private class CachedWidget { private String text; private RS2Widget widget; public CachedWidget(final String text) { this.text = text; } public RS2Widget getWidget(final Widgets widgets) { if (widget == null) cacheWidget(widgets); return widget; } private void cacheWidget(final Widgets widgets) { RS2Widget widget = null; if (text != null) widget = widgets.getWidgetContainingText(text); this.widget = widget; } } private enum Armour { LEATHER_GLOVES("Gloves", "Make All pairs of Leather gloves"), LEATHER_BOOTS("Boots", "Make All pairs of Leather boots"), LEATHER_COWL("Cowl", "Make All Cowls"); private String armour, option; Armour(String armour, String option) { this.armour = armour; this.option = option; } private String getArmour() { return armour; } private String getOption() { return option; } } private boolean canCraftArmour() { return getInventory().contains("Thread") && getInventory().contains("Needle") && getInventory().contains("Leather") && !getBank().isOpen(); } private boolean isItemSelected(final String item) { String selectedName = getInventory().getSelectedItemName(); return selectedName != null && selectedName.equals(item); } private boolean mustContinue() { return getDialogues().isPendingContinuation(); } private boolean isAmountPromptVisible() { Optional<RS2Widget> amountWidget = getWidgets().getAll().stream() .filter(widg -> widg.getMessage().contains("Enter amount")).findFirst(); return amountWidget.isPresent() && amountWidget.get().isVisible(); } private void openBank() throws InterruptedException { if (getBank().open()) new CSleep(() -> getBank().isOpen(), 5_000).sleep(); } } enjoy noobs has not been tested so idk if it actually works Edited July 17, 2016 by Acerd 2 Quote Link to comment Share on other sites More sharing options...
Solution Posted July 17, 2016 Share Posted July 17, 2016 gz? Quote Link to comment Share on other sites More sharing options...
Acerd Posted July 18, 2016 Author Share Posted July 18, 2016 gz? i only made it for some plebs 1 Quote Link to comment Share on other sites More sharing options...
Santonio Posted July 18, 2016 Share Posted July 18, 2016 What? Quote Link to comment Share on other sites More sharing options...
Antonio Kala Posted July 18, 2016 Share Posted July 18, 2016 why do I need 10 crafting? Quote Link to comment Share on other sites More sharing options...
Acerd Posted July 18, 2016 Author Share Posted July 18, 2016 idk?? people requested it so i made it, its probably for bow string 1 Quote Link to comment Share on other sites More sharing options...
Chris Posted July 18, 2016 Share Posted July 18, 2016 thx for enums Quote Link to comment Share on other sites More sharing options...
Farcast Posted July 18, 2016 Share Posted July 18, 2016 Yeah, I saw this requested earlier today. Nice. Quote Link to comment Share on other sites More sharing options...
wadbot1 Posted July 20, 2016 Share Posted July 20, 2016 good script Quote Link to comment Share on other sites More sharing options...
DrDu Posted December 23, 2016 Share Posted December 23, 2016 (edited) gg Edited December 23, 2016 by DrDu Quote Link to comment Share on other sites More sharing options...
gearing Posted December 23, 2016 Share Posted December 23, 2016 gz, maybe implement it to switch over to making bowstrings, leave it at lumby with stuff and it will automatically take you to 99craft ----->profit Quote Link to comment Share on other sites More sharing options...