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

Script not running

Featured Replies

So I wrote a local script with Eclipse and tried to export it as a .jar file to run it.

The problem is that it does not start. When I select it in OSBot, it does nothing.

My guess is that it has something to do with JRE versions not mathcing (1.7 compared to 1.8), but since I am a newbie with this, maybe someone can take me through how to check this propertly...?
Should I just clean my PC from Java and install JRE 1.7?

Much appreciated <3

Edited by Magerange

You most likely attempted to initialize an instance of any OSBot class outside the methods defined in the Script class, eg:

@ScriptManifest(name = "Lol", author = "Token", version = 1.0, info = "", logo = "")
public class Lol extends Script {
	
  NPC x = npcs.closest("Guard"); // script won't start because of this
  NPC y;
  
  @Override
  public void onStart() throws InterruptedException {
    // something 
    y = npcs.closest("Guard"); // but this is fine
  }
  
  @Override
  public int onLoop() throws InterruptedException {
    // something 
    return 69;
  }
  
}

Post your code if that's not the case because this is definitely a programming error 

  • Author
10 minutes ago, Token said:

You most likely attempted to initialize an instance of any OSBot class outside the methods defined in the Script class, eg:


@ScriptManifest(name = "Lol", author = "Token", version = 1.0, info = "", logo = "")
public class Lol extends Script {
	
  NPC x = npcs.closest("Guard"); // script won't start because of this
  NPC y;
  
  @Override
  public void onStart() throws InterruptedException {
    // something 
    y = npcs.closest("Guard"); // but this is fine
  }
  
  @Override
  public int onLoop() throws InterruptedException {
    // something 
    return 69;
  }
  
}

Post your code if that's not the case because this is definitely a programming error 

Alright, so here is what I've been working on:

@ScriptManifest(author = "Magerange", name = "JugFiller", info = "Fills jugs with water in east Falador", version = 1.0, logo = "")
public final class Main extends Script  {

	private final Area Pump = new Area (2947, 3382, 2948, 3383);

@Override
    public final int onLoop() throws InterruptedException {
 if (canFill()){
	 fill();
 } else {
	 bank();
 }
 return random(175, 270);
    }
    
private boolean canFill() {
	return getInventory().contains("Jug");
}
private boolean pumpUsable(){
	return Pump.contains(myPlayer());
}

Entity wPump = getObjects().closest("Waterpump");

private void fill() {
	if (!Pump.contains(myPosition())){
		getWalking().webWalk(Pump);
	} else if (pumpUsable()) {
		if (wPump != null)
	inventory.interact("Use","Jug");
		wPump.interact("Use");
	} else {
		new ConditionalSleep(1500) {
			@Override
			public boolean condition() {
				return myPlayer().isAnimating();
			}
		}.sleep();
	}
}

	private void bank() throws InterruptedException {
    	if(!Banks.FALADOR_EAST.contains(myPosition())) {
    		getWalking().webWalk(Banks.FALADOR_EAST);
    	} else if (!getBank().isOpen()) {
    		getBank().open();
    	} else if (!getInventory().isEmptyExcept("Jug")) {
    		getBank().depositAll();
    	} else if (getBank().contains("Jug")) {
    		getBank().withdrawAll("Jug");
    	} else  {
    		stop(true);
    	}
    }
    }

 

4 minutes ago, Magerange said:

Alright, so here is what I've been working on:


@ScriptManifest(author = "Magerange", name = "JugFiller", info = "Fills jugs with water in east Falador", version = 1.0, logo = "")
public final class Main extends Script  {

	private final Area Pump = new Area (2947, 3382, 2948, 3383);

@Override
    public final int onLoop() throws InterruptedException {
 if (canFill()){
	 fill();
 } else {
	 bank();
 }
 return random(175, 270);
    }
    
private boolean canFill() {
	return getInventory().contains("Jug");
}
private boolean pumpUsable(){
	return Pump.contains(myPlayer());
}

Entity wPump = getObjects().closest("Waterpump");

private void fill() {
	if (!Pump.contains(myPosition())){
		getWalking().webWalk(Pump);
	} else if (pumpUsable()) {
		if (wPump != null)
	inventory.interact("Use","Jug");
		wPump.interact("Use");
	} else {
		new ConditionalSleep(1500) {
			@Override
			public boolean condition() {
				return myPlayer().isAnimating();
			}
		}.sleep();
	}
}

	private void bank() throws InterruptedException {
    	if(!Banks.FALADOR_EAST.contains(myPosition())) {
    		getWalking().webWalk(Banks.FALADOR_EAST);
    	} else if (!getBank().isOpen()) {
    		getBank().open();
    	} else if (!getInventory().isEmptyExcept("Jug")) {
    		getBank().depositAll();
    	} else if (getBank().contains("Jug")) {
    		getBank().withdrawAll("Jug");
    	} else  {
    		stop(true);
    	}
    }
    }

 

It's exactly what I said, you initialized wPump outside the Script methods

  • Author
5 minutes ago, Token said:

It's exactly what I said, you initialized wPump outside the Script methods

Thanks! Should I make a new method for it?

10 minutes ago, Magerange said:

Alright, so here is what I've been working on:


@ScriptManifest(author = "Magerange", name = "JugFiller", info = "Fills jugs with water in east Falador", version = 1.0, logo = "")
public final class Main extends Script  {

	private final Area Pump = new Area (2947, 3382, 2948, 3383);

@Override
    public final int onLoop() throws InterruptedException {
 if (canFill()){
	 fill();
 } else {
	 bank();
 }
 return random(175, 270);
    }
    
private boolean canFill() {
	return getInventory().contains("Jug");
}
private boolean pumpUsable(){
	return Pump.contains(myPlayer());
}

Entity wPump = getObjects().closest("Waterpump");

private void fill() {
	if (!Pump.contains(myPosition())){
		getWalking().webWalk(Pump);
	} else if (pumpUsable()) {
		if (wPump != null)
	inventory.interact("Use","Jug");
		wPump.interact("Use");
	} else {
		new ConditionalSleep(1500) {
			@Override
			public boolean condition() {
				return myPlayer().isAnimating();
			}
		}.sleep();
	}
}

	private void bank() throws InterruptedException {
    	if(!Banks.FALADOR_EAST.contains(myPosition())) {
    		getWalking().webWalk(Banks.FALADOR_EAST);
    	} else if (!getBank().isOpen()) {
    		getBank().open();
    	} else if (!getInventory().isEmptyExcept("Jug")) {
    		getBank().depositAll();
    	} else if (getBank().contains("Jug")) {
    		getBank().withdrawAll("Jug");
    	} else  {
    		stop(true);
    	}
    }
    }

 

As Token said; I'd move the initialization of wPump to the fill() method.

15 minutes ago, Magerange said:

Thanks! Should I make a new method for it?

Just initialize it inside a method when you actually need it

  • Author

Thanks to both of you! It works now. However, I have found out that my conditionalsleep does not function propertly. I think I have set wrong parameter for it, because the account doesn't always animate while filling jugs.

How could I replace it so it sleeps for x miliseconds? Do I have to change a lot of code?

If there is an error before the onStart method is called it will simply not log the error and leave you clueless. Make sure there is no code executing before the onStart method that accesses any osbot library, such as during variable initialization. It's simply throwing NPE and suppressing the error..

Not your fault, bad programming on the APIs part not logging those exceptions. 

Edited by dmmslaver

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

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.