Jump to content

Problem with sleep()


Mumble

Recommended Posts

I'm trying to create a basic edgeville yew cutting script just to learn a little bit, 

package edgeChopper;



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 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);
	
	 private enum State {
	        CHOP, WALK_TO_BANK, BANK, WALK_TO_CHOP
	    };
	    
	    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;
	    }

    @[member=Override]
    public void onStart() {
        //Code here will execute before the loop is started
log("hopefully this fucking works");


    }
    
    @[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)




    }


}

In the onLoop() section I'm confronted with an Unhandled exception type error and I'm not sure how to fix it.

 

 

Thanks for any help.

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...