bulv3 Posted April 5, 2019 Share Posted April 5, 2019 First script How could I improve this shitty script ?? Features: - crafts gold rings at alkharid - Banks at alkharid and runs back to alkharid furnace Requirements: - 5 lvl crafting gold bars and ring mold in inventory How to start: Start at alkharid bank with ring mould in inventory. Source code: import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(name = "Gold rings maker", logo = "", version = 1, author = "bulv3", info = "Crafts gold rings at Al Kharid") public class Main extends Script { @Override public void onStart() { log("Let's make some gold rings"); } @Override public int onLoop() throws InterruptedException { NPC bank = getNpcs().closest(npc -> npc.getName().startsWith("Banker")); Area alkharbank = new Area(3269, 3170, 3272, 3163); Area alfurn = new Area(3272, 3187, 3278, 3184); RS2Object furnace = getObjects().closest(object -> object!=null && object.getName().equals("Furnace") && getMap().canReach(object) && alfurn.contains(object)); RS2Widget goldring = getWidgets().get(446,7); if (!inventory.contains("Gold Bar") && Banks.AL_KHARID.contains(myPlayer()) && bank.isVisible() && !getBank().isOpen()){ log("opening a bank interface"); bank.interact("Bank"); new ConditionalSleep(10000) { @Override public boolean condition() throws InterruptedException { return getBank().isOpen(); } }.sleep(); } else if (!inventory.contains("Gold Bar") && alkharbank.contains(myPlayer()) && bank.isVisible() && getBank().isOpen() && inventory.contains("Gold ring")){ log("Depositing gold rings"); getBank().depositAllExcept("Ring mould"); } else if (!inventory.contains("Gold Bar") && alkharbank.contains(myPlayer()) && bank.isVisible() && getBank().isOpen() && !inventory.contains("Gold ring")){ log("Getting gold bars"); getBank().withdrawAll("Gold bar"); } else if (inventory.contains("Gold Bar") && alkharbank.contains(myPlayer()) && bank.isVisible()){ log("Running to Furniture"); getWalking().webWalk(alfurn); } else if (inventory.contains("Gold bar") && alfurn.contains(myPlayer()) && !myPlayer().isAnimating() && !widgets.isVisible(446,7)){ log("opening a Smelting interface"); furnace.interact("Smelt"); new ConditionalSleep(3000) { @Override public boolean condition() throws InterruptedException { return !getInventory().contains("Gold bar") || getDialogues().isPendingContinuation(); } }.sleep(); } else if (inventory.contains("Gold bar","Ring mould") && alfurn.contains(myPlayer()) && !myPlayer().isAnimating() && widgets.isVisible(446,7)){ log("Crafting gold rings"); goldring.interact("Make-All"); new ConditionalSleep(100000) { @Override public boolean condition() throws InterruptedException { return !getInventory().contains("Gold bar") || getDialogues().isPendingContinuation(); } }.sleep(); } else if (!inventory.contains("Gold bar") && !myPlayer().isAnimating() && alfurn.contains(myPlayer())){ log("Running to Al Kharid bank"); getWalking().webWalk(alkharbank); } return 1500;} } Quote Link to comment Share on other sites More sharing options...
Imthabawse Posted May 19, 2019 Share Posted May 19, 2019 Use Banks.constants in API instead of creating area yourself. Would look like Banks.AL_KHARID or something like that. Quote Link to comment Share on other sites More sharing options...
The Devil Posted May 21, 2019 Share Posted May 21, 2019 Edgeville is f2p no requirements now. Use that instead of al kharid. 1 Quote Link to comment Share on other sites More sharing options...