skylar15100 Posted February 21, 2016 Share Posted February 21, 2016 (edited) player moves to tree area but gets stuck in state "Finding Tree". import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.input.mouse.MouseDestination; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; 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.Skill; import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @SuppressWarnings("unused") @ScriptManifest(author = "CloudCode", info = "Simple Treecutting script", name = "Logger", version = 1, logo = "") public class Main extends Script { private long timeStart; private String state = "Initializing.."; private int invCount = 0; private int LogsChopped = 0; private int lastMA = 0; Area westBank = new Area( new Position(3167,3414,0), new Position(3184,3435,0)); Area VarrockOak = new Area( new Position(3185, 3436, 0), new Position(3168, 3418, 0)); @Override public void onStart() { log("Welcome to 'Logger' by CloudCode"); log("Submit any Errors to me on the forums and i'd be happy to take a look."); timeStart = System.currentTimeMillis(); getExperienceTracker().start(Skill.WOODCUTTING); } @Override public void onPaint(Graphics2D g) { long timeElapsed = System.currentTimeMillis() - timeStart; long seconds = (timeElapsed / 1000) % 60; long minutes = (timeElapsed / (1000 * 60)) % 60; long hours = (timeElapsed / (1000 * 60 * 60)) % 24; g.setFont(new Font("Trebuchet MS", Font.PLAIN, 14)); g.setColor(Color.white); g.drawString("x", (int)getMouse().getPosition().getX() - 4, (int)getMouse().getPosition().getY() + 5); g.drawString(state, 8, 50); g.drawString("Time Running: " + (hours >= 10 ? "" + hours : "0" + hours) + ":" + (minutes >= 10 ? "" + minutes : "0" + minutes) + ":" + (seconds >= 10 ? "" + seconds : "0" + seconds), 8, 65); g.drawString("XP Gained: " + getExperienceTracker().getGainedXP(Skill.WOODCUTTING) + " (" + getExperienceTracker().getGainedLevels(Skill.WOODCUTTING) + ")", 8, 80); g.drawString("Logs Chopped " + LogsChopped, 8, 95); } private void randomizeMouse() { lastMA++; if (lastMA > 4) { int i = random(5); switch (i) { case 0: case 1: getMouse().moveOutsideScreen(); break; case 2: getMouse().moveRandomly(); break; case 3: getMouse().moveSlightly(); lastMA = 3; break; case 4: getMouse().moveVerySlightly(); break; case 5: getTabs().open(randomTab()); if (getTabs().getOpen() == Tab.SKILLS) { getMouse().move(704, 283); } } lastMA = 0; } } private Tab randomTab() { int i = random(6); switch(i) { case 0: case 1: return Tab.INVENTORY; case 2: return Tab.EQUIPMENT; case 3: return Tab.ATTACK; case 4: return Tab.SKILLS; case 5: return Tab.FRIENDS; case 6: return Tab.QUEST; } return Tab.SKILLS; } @Override public int onLoop() throws InterruptedException { if (getInventory().isFull() && !westBank.contains(myPlayer()) && !getBank().isOpen()) { state = "Banking..."; getWalking().webWalk(new Position(Banks.VARROCK_WEST.getRandomPosition())); } if (getInventory().isFull() && westBank.contains(myPlayer()) && !getBank().isOpen()) { RS2Object bank = getObjects().closest("Bank booth"); state = "Opening bank"; if (bank != null) { if (bank.interact("Bank")) { state = "Depositing items"; sleep(1000); } } } if (getInventory().isFull() && westBank.contains(myPlayer()) && getBank().isOpen()) { getBank().depositAllExcept("Axe"); while (getInventory().contains("Logs, Oak Logs, Yew Logs")) { sleep(100); } state = "Closing bank"; getBank().close(); } if (!getInventory().isFull() && !VarrockOak.contains(myPlayer()) && !getBank().isOpen() ) { state = "Walking to Oak Trees"; getWalking().webWalk(new Position(3168 + random(3), 3418 + random(3), 0)); } if (!getInventory().isFull() && VarrockOak.contains(myPlayer())) { NPC spot = getNpcs().closest("Oak"); state = "Finding Tree"; Entity tree = getObjects().closestThatContains("Oak"); if (tree != null){ if (tree.isVisible()){ if (!myPlayer().isMoving() && !myPlayer().isAnimating()){ tree.interact("Chop Down"); sleep(random(500,800)); } } } } while (myPlayer().isAnimating()) { state = "Chopping Tree.."; randomizeMouse(); if (getInventory().getEmptySlots() != invCount && VarrockOak.contains(myPlayer())) { invCount = getInventory().getEmptySlots(); LogsChopped += 1; } sleep(random (500, 1000)); } return random(200, 300); } @Override public void onExit() { } } Edited February 21, 2016 by skylar15100 Quote Link to comment Share on other sites More sharing options...
Explv Posted February 21, 2016 Share Posted February 21, 2016 (edited) In the future if you post code, please use the code tags, otherwise it is completely unreadable: The issue in your code as far as I can see, is you have tree.interact("Chop Down") It should be tree.interact("Chop down") The interaction text must be exact. There are quite a few other errors in your Script, but I don't have the time to write down what they are. Edited February 21, 2016 by Explv 3 Quote Link to comment Share on other sites More sharing options...
Botre Posted February 21, 2016 Share Posted February 21, 2016 If you use code tags and / or pastebin you'll greatly increase the odds of getting your question answered. Most of us aren't hieroglyph experts. Quote Link to comment Share on other sites More sharing options...
skylar15100 Posted February 21, 2016 Author Share Posted February 21, 2016 In the future if you post code, please use the code tags, otherwise it is completely unreadable: The issue in your code as far as I can see, is you have tree.interact("Chop Down") It should be tree.interact("Chop down") The interaction text must be exact. There are quite a few other errors in your Script, but I don't have the time to write down what they are. If you use code tags and / or pastebin you'll greatly increase the odds of getting your question answered. Most of us aren't hieroglyph experts. Thank you for the help, sorry i've seen code tags used on other posts but i couldn't out how to use them. Quote Link to comment Share on other sites More sharing options...
LetMeHolla Posted February 23, 2016 Share Posted February 23, 2016 log("Welcome to 'Logger' by CloudCode");log("Submit any Errors to me on the forums and i'd be happy to take a look."); hehe Quote Link to comment Share on other sites More sharing options...