Jump to content

Script won't run whatsoever


CloudCode

Recommended Posts

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 org.osbot.rs07.api.util.ItemContainer;
import org.osbot.rs07.api.Equipment;

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;
	int staticLevel = getSkills().getStatic(Skill.WOODCUTTING);
	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);
	}
	@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 (staticLevel < 6 && !getInventory().contains(1349, 1350,1351, 1352)) {
				getWalking().webWalk(new Position(Banks.VARROCK_WEST.getRandomPosition()));
				bank.open();
				bank.withdraw(1349, 1350);
			}
		}
		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()) {
			getWalking().webWalk(new Position(Banks.VARROCK_WEST.getRandomPosition()));
			bank.open();
			bank.depositAll(1521, 1522);
		}
		if (!getInventory().contains(1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362)) {
			state = "Getting a hatchet...";
			getWalking().webWalk(new Position(Banks.VARROCK_WEST.getRandomPosition()));
			getBank().open();
			bank.withdraw(1349 | 1350, 1);
		}
		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..";
			if (getInventory().getEmptySlots() != invCount && VarrockOak.contains(myPlayer())) {
				invCount = getInventory().getEmptySlots();
				LogsChopped += 1;
			}
			sleep(random (500, 1000));
		}
		return random (200, 300);	
	}
	
	@Override
	public void onExit() {
	}
}
	

Am i missing something? My code won't run at all. I can select it as a local script but when i hit start it does nothing.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...