Skip to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Problem with sleep()

Featured Replies

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.

  • Author

to save time, which line does the unhandled exception occur at?

1de9e377dca66172fc2022d537f69a13.png

 

to save time, which line does the unhandled exception occur at?

1de9e377dca66172fc2022d537f69a13.png

 

 

could you show what is on these lines?

drink a cup of chammomile tea an hr before bed don't use any backlit devices an hr before bed

Why are you trolling in the scripter section? 

  • Author

could you show what is on these lines?

 

 

d1e2f03c008a18f44d1d757542e3b28a.png

Surround your sleeps with try and catch, for example wherever you have a sleep:

try {
			sleep(random(1000, 2000));
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

d1e2f03c008a18f44d1d757542e3b28a.png

 

what lol add my skype, probably save more time: precise.scripting

 

 

Surround your sleeps with try and catch, for example wherever you have a sleep:

try {
			sleep(random(1000, 2000));
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

 

no need since onLoop throws Interrupted Exception

  • Author

what lol add my skype, probably save more time: precise.scripting

 

 

no need since onLoop throws Interrupted Exception

 

 

Turns out I just needed to save the program so it would update.

 

Thanks to this guy I've managed to fix this issue.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.