Jump to content

hotpoket

Members
  • Posts

    1
  • Joined

  • Last visited

  • Feedback

    0%

Profile Information

  • Gender
    Male

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

hotpoket's Achievements

Newbie

Newbie (1/10)

0

Reputation

  1. I started with scripting yesterday, and I was wondering if I could get some feedback on a script I made to see if there are some glaring errors / best practices that I could implement. The purpose of the script is to perform a herb run. I am aware that this script does not account for dead herbs. I think the biggest issues are the sleeps, and I implement the while(true) loops and I believe a conditional sleep could be used instead but I haven't been able to implement them. @ScriptManifest(author = "HotPoket", info = "My first script", name = "Herb Running", version = 0, logo = "") public class Main extends Script { private static Area camelotPatch = new Area(2810,3460,2820, 3470); private static Area mortPatch = new Area(3600, 3528, 3605, 3533); private static Area ardyPatch = new Area(2668,3376, 2672, 3372); private static Area falPatch = new Area(3055, 3313, 3060, 3308); private static Area camBank = new Area(2808, 3440, 2810, 3438); private static int ardyCloakCharges = 0; @Override public void onStart() throws InterruptedException { if (checkSupplies()) { moveToCamelot(); farmPatch(); moveToMort(); farmPatch(); moveToFal(); farmPatch(); moveToArdy(); farmPatch(); } else { log("Not enough supplies to perform a herb run"); stop(); } } @Override public int onLoop() throws InterruptedException { return random(200, 300); } @Override public void onExit() { log("Thanks for running my Tea Thiever!"); } @Override public void onPaint(Graphics2D g) { } private boolean checkSupplies() throws InterruptedException { if (!getInventory().contains("Rake")) { log("Rake not found"); return false; } if (!getInventory().contains("Seed dibber")) { log("Seed Dibber Not Found"); return false; } if (!getInventory().contains("Spade")) { log("Spade not found"); return false; } if (getInventory().getAmount("Law rune") < 3 || getInventory().getAmount("Water rune") < 3 && getInventory().getAmount("Air rune") < 8) { log("Teleport runes not found"); return false; } if (!getInventory().contains("Ectophial")){ log("Ectophial not found"); return false; } Item [] myItems = getInventory().getItems(); int seedAmount = 0; int compostAmount = 0; for (Item i : myItems) { if (i != null && i.getName().contains("seed")) { seedAmount = i.getAmount(); } if (i!= null && i.getName().contains("post") && !i.isNote()) { compostAmount = (int) getInventory().getAmount(i.getName()); } } if (seedAmount < 4) { log("Seeds not found -- Seed Amount: " + seedAmount); return false; } return true; } private void noteHerbs() throws InterruptedException { Item [] myItems = getInventory().getItems(); for (Item i : myItems) { if (i != null && !i.isNote() && i.getName().contains("Grimy")) { i.interact("Use"); sleep(2000); NPC tl = npcs.closest("Tool Leprechaun"); tl.interact("Use"); sleep(2000); break; } } } private void banking() throws InterruptedException { getBank().open(); long numBuckets = getInventory().getAmount("Bucket"); if (numBuckets > 0) { getBank().deposit("Bucket", (int) numBuckets); } long numCompost = getInventory().getAmount("Ultracompost"); if (numCompost > 0) { getBank().depositAll(21483); } getBank().withdraw(21483, 5); } private void moveToMort() throws InterruptedException { getInventory().getItem("Ectophial").interact("Empty"); sleep(5000); walking.webWalk(mortPatch); } private void moveToCamelot() throws InterruptedException { log("Let's get started!"); magic.castSpell(Spells.NormalSpells.CAMELOT_TELEPORT); sleep(5000); walking.webWalk(camBank); banking(); walking.webWalk(camelotPatch); } private void moveToArdy() throws InterruptedException { log("Moving to Ardy"); magic.castSpell(Spells.NormalSpells.ARDOUGNE_TELEPORT); sleep(5000); walking.webWalk(ardyPatch); } private void moveToFal() throws InterruptedException { log("Moving to Falador"); magic.castSpell(Spells.NormalSpells.FALADOR_TELEPORT); sleep(5000); walking.webWalk(falPatch); } private int whichPatch() { if (camelotPatch.contains(myPlayer())) { log("Player is in the CamelotPatch"); return 8151; } { if (mortPatch.contains(myPlayer())) { return 8153; } if (ardyPatch.contains(myPlayer())) { log("Player is in the Ardy Patch"); return 8152; } if (falPatch.contains(myPlayer())) { log("Player is in the Falador Patch"); return 8150; } } log("Player is not at a patch -- Closing Script"); stop(); return 0; } private void farmPatch() throws InterruptedException { sleep(6000); noteHerbs(); RS2Object patch = getObjects().closest(whichPatch()); if (patch != null) { log("Found patch"); while (true) { String [] availableActions = patch.getActions(); if (availableActions[0] != null && availableActions[0].contains("Rake")) { log("yes"); patch.interact("Rake"); sleep(10000); } else break; } while (true) { String [] availableActions = patch.getActions(); if (availableActions[0] != null && availableActions[0].contains("Pick")) { log("yes"); patch.interact("Pick"); sleep(10000); } else break; } getInventory().dropAll("Weeds"); sleep(2000); patch = getObjects().closest("Herb patch"); Item compost = getInventory().getItem("Ultracompost"); compost.interact("Use"); sleep(3000); patch.interact("Use"); sleep(3000); Item i = getInventory().getItem("Avantoe seed"); i.interact("Use"); sleep(3000); patch.interact("Use"); sleep(3000); noteHerbs(); } } }
×
×
  • Create New...