January 19, 20179 yr So I tried making an edgeville yew chopper, I don't know if it works, so if someone could test it for me. DL Link: https://mega.nz/#!PsxTxQbS!KaI0RGrkwtj-WK0SlXCECjB7uS5-8lEWA7bRed0FHUM Start at edgeville bank with an axe equipped. package edgeChopper; //this script is used to walk from a bank to a yew tree in edgeville and then chop them. import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.input.mouse.MiniMapTileDestination; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.ui.Skill; import java.awt.*; @ScriptManifest(name = "edgeYews", author = "Mumble", version = 1.0, info = "", logo = "") public class edgeChopper extends Script { public final int ALIVE_YEW=38755; private Area BANK_AREA = new Area(3098, 3488, 3092, 3498); private Area CHOP_AREA = new Area(3089, 3468, 3085, 3482); //Areas are coordinates based on a square //You can do more than just a square but idk how yet // https://explv.github.io/ //Great map for coordinates. private long startTime; private enum State { CHOP, WALK_TO_BANK, BANK, WALK_TO_CHOP }; //states are used to describe what the character is doing private State getState() { if (inventory.isFull() && CHOP_AREA.contains(myPlayer())) return State.WALK_TO_BANK; if (!inventory.isFull() && BANK_AREA.contains(myPlayer())) return State.WALK_TO_CHOP; if (inventory.isFull() && BANK_AREA.contains(myPlayer())) return State.BANK; return State.CHOP; } //If players inventory is full and they're in the chop area then they walk to bank //if players inventory is full and they're in the bank area, bank //if players inventory is NOT full and in the bank, walk to chop area //if player is not full inventory and is at the chop area, then chop public final String formatTime(final long ms){ long s = ms / 1000, m = s / 60, h = m / 60; s %= 60; m %= 60; h %= 24; return String.format("%02d:%02d:%02d", h, m, s); } // timing for recording xp gain public final String formatValue(final int v){ return (v > 1_000_000) ? String.format("%.2fm", (double) (v / 1_000_000)) : (v > 1000) ? String.format("%.1fk", (double) (v / 1000)) : v + ""; } //xp gain recording stuff @[member='Override'] public void onStart() { //Code here will execute before the loop is started log("hopefully this fucking works"); startTime = System.currentTimeMillis(); getExperienceTracker().start(Skill.WOODCUTTING); } @[member='Override'] public void onExit() { //Code here will execute after the script ends } @[member='Override'] public int onLoop() throws InterruptedException { switch (getState()) { case CHOP: if (!myPlayer().isAnimating()) { RS2Object tree = objects.closest(ALIVE_YEW); if (tree != null) { if (tree.interact("Chop")) sleep(random(1000, 1500)); } } break; case WALK_TO_BANK: getWalking().webWalk(BANK_AREA); sleep(random(1500, 2500)); break; case WALK_TO_CHOP: getWalking().webWalk(CHOP_AREA); sleep(random(1500, 2500)); break; case BANK: RS2Object bankBooth = objects.closest("Bank booth"); if (bankBooth != null) { if (bankBooth.interact("Bank")) { while (!bank.isOpen()) sleep(250); bank.depositAll(); } } break; } return 100; //The amount of time in milliseconds before the loop starts over } @[member='Override'] public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) } } Edited January 19, 20179 yr by Mumble
January 19, 20179 yr Looks good! Be careful using IDs though, instead of using public final int ALIVE_YEW=38755; RS2Object tree = objects.closest(ALIVE_YEW); just use RS2Object tree = objects.closest("Yew tree"); to prevent ID changes breaking the script Edited January 19, 20179 yr by BoysNoize
February 5, 20179 yr How does this code work? case CHOP: if (!myPlayer().isAnimating()) { RS2Object tree = objects.closest(ALIVE_YEW); if (tree != null) { if (tree.interact("Chop")) sleep(random(1000, 1500)); } } I am trying to learn how to code, so I try to take a look at others source code when they post it. However, before sleep, your final line is a conditional. So, from my understanding of code, it will check to see if that value is True or False. The code to execute is supposed to come below a conditional statement, and only executes if that statement evaluates to true (from what I have learned). So, at what point does the script actually execute the code 'tree.interact("Chop")'.The same structure is used in your BANK case, so the same idea would apply. Edited February 5, 20179 yr by WindPower
February 5, 20179 yr Only chops is the rs2 object tree of Yew is there; and checks it exists. Chops of player isn't moving or animating (the !). Sleep is purely there to allow player time to cut tree.
February 6, 20179 yr Author 1 hour ago, Montana of 300 said: Only chops is the rs2 object tree of Yew is there; and checks it exists. Chops of player isn't moving or animating (the !). Sleep is purely there to allow player time to cut tree. yeah what he said