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.

Suggestions & Help

Featured Replies

I don't know why, but the bot tries to drop everything in the inventory, no matter the state (even though I never say to drop anything). There's only 1 error set shown in the console, but I don't know what it's trying to refer to as to what's causing it, although it does appear to be from onExit, based on the log. Also, any general suggestions you could provide for OSB scripting would prove beneficial. Thank you.

Error:

[INFO][Bot #1][02/10 10:06:44 PM]: Loaded 4 built-in random solvers!
[INFO][Bot #1][02/10 10:06:45 PM]: Welcome to My Fisher by Engineer.
[INFO][Bot #1][02/10 10:06:45 PM]: Started script : My Fisher
[INFO][Bot #1][02/10 10:06:46 PM]: Terminating script My Fisher...
[WARN][Bot #1][02/10 10:06:51 PM]: Event executor is taking too long to suspend; terminating now...
[WARN][Bot #1][02/10 10:06:56 PM]: Script executor is taking too long to suspend; restarting now...
[ERROR][Bot #1][02/10 10:06:56 PM]: Error in bot executor!
java.lang.ThreadDeath
	at java.lang.Thread.stop(Unknown Source)
	at org.osbot.rs07.event.ScriptExecutor.restart(wh:626)
	at org.osbot.rs07.event.ScriptExecutor.suspend(wh:358)
	at org.osbot.rs07.event.ScriptExecutor.stop(wh:215)
	at org.osbot.rs07.event.ScriptExecutor.stop(wh:252)
	at org.osbot.dc.run(ww:172)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
[INFO][Bot #1][02/10 10:06:56 PM]: Thanks for running My Fisher!
[INFO][Bot #1][02/10 10:06:56 PM]: Script My Fisher has exited!

 

Main.java

import org.osbot.rs07.api.model.Entity;
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 java.awt.*;

@ScriptManifest(author = "Engineer", info = "Fishin Script Yo", name = "My Fisher", version = 0, logo = "")
public class Main extends Script {
	@Override
	public void onStart() {
		log("Welcome to My Fisher by Engineer.");
	}

	private enum State {
		FISH, BANK, WALK_BANK, WALK_FISHING, WAIT
	};

	private State getState() {
		Area fishing_area = new Area(2714, 3535, 2731, 3523);

		if (fishing_area.contains(myPosition())) {
			return State.FISH;
		}
		
		if (Banks.CAMELOT.contains(myPosition())) {
			return State.BANK;
		}
		
		if (getInventory().isFull()) {
			return State.WALK_BANK;
		}
		
		if (getState().equals("BANK")) {
			if (!getInventory().contains("Raw trout") && !getInventory().contains("Raw salmon")) {
				return State.WALK_FISHING;
			} else {
				return State.WALK_BANK;
			}
		}
		
		return State.WAIT;
	}

	@Override
	public int onLoop() throws InterruptedException {
		switch (getState()) {
			case FISH:
				log("Fishing");
				Entity fishing_spot = getObjects().closest("Fishing spot");
				
				if (fishing_spot != null && fishing_spot.interact("Lure")) {
				    new Sleep(() -> myPlayer().isAnimating() || !fishing_spot.exists(), 2000).sleep();
				}
				
				break;
			case BANK:
				log("Banking");
				if (!getBank().isOpen()) {
				    if (getBank().open()) {
				    	new Sleep(() -> getBank().isOpen(), 1000).sleep();
				    	getBank().depositAllExcept("Fly fishing rod", "Feather");
				    }
				}
				
				break;
			case WALK_BANK:
				log("Walking to Bank");
				getWalking().webWalk(Banks.CAMELOT);
				break;
			case WALK_FISHING:
				log("Walking to fishing grounds");
				getWalking().webWalk(new Position(2723, 3530, 0));
				break;
			case WAIT:
				sleep(random(500, 700));
				break;
		}
		
		return random(200, 300);
	}

	@Override
	public void onExit() {
		log("Thanks for running My Fisher!");
	}

	@Override
	public void onPaint(Graphics2D g) {

	}
}

 

Sleep.java

import org.osbot.rs07.utility.ConditionalSleep;
import java.util.function.BooleanSupplier;

public final class Sleep extends ConditionalSleep {

    private final BooleanSupplier condition;

    public Sleep(final BooleanSupplier condition, final int timeout) {
        super(timeout);
        this.condition = condition;
    }

    @Override
    public final boolean condition() throws InterruptedException {
        return condition.getAsBoolean();
    }

    public static boolean sleepUntil(final BooleanSupplier condition, final int timeout) {
        return new Sleep(condition, timeout).sleep();
    }
}

 

  • Author
5 minutes ago, Juggles said:

I don't see how your script could possibly be dropping the items 

Me either. When I start it, it also starts up some paint splash too. It makes 0 damn sense. I only have the two Java files I posted, and the OSB Jar of course. I don't get it.

  • Author

Edit

I've created an area to determine if the player is within the fishing grounds. But, the player does not interact with the fishing spot. I was looking at some snippets / tutorials, and this method looked like a viable one to use, ex for skilling.

Entity fishing_spot = getObjects().closest("Fishing spot");
				
if (fishing_spot != null && fishing_spot.interact("Lure")) {
  new Sleep(() -> myPlayer().isAnimating() || !fishing_spot.exists(), 2000).sleep();
}

The Sleep class is posted above.

 

Error is this: (fishing_spot.interact("Lure") is the problem item)

[ERROR][Bot #1][02/10 10:58:47 PM]: Error in script executor!
java.lang.NullPointerException
    at Main.onLoop(Main.java:40)
    at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(wh:281)
    at java.lang.Thread.run(Unknown Source)

 

For some reason, fishing_spot is returning null. I'm not even 2 tiles from a fishing spot. And it's spelled correctly, with proper capitalization. I don't get why it's null.

Edited by BrainDeadGenius

34 minutes ago, BrainDeadGenius said:

Edit

I've created an area to determine if the player is within the fishing grounds. But, the player does not interact with the fishing spot. I was looking at some snippets / tutorials, and this method looked like a viable one to use, ex for skilling.


Entity fishing_spot = getObjects().closest("Fishing spot");
				
if (fishing_spot != null && fishing_spot.interact("Lure")) {
  new Sleep(() -> myPlayer().isAnimating() || !fishing_spot.exists(), 2000).sleep();
}

The Sleep class is posted above.

 

Error is this: (fishing_spot.interact("Lure") is the problem item)

[ERROR][Bot #1][02/10 10:58:47 PM]: Error in script executor!
java.lang.NullPointerException
    at Main.onLoop(Main.java:40)
    at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(wh:281)
    at java.lang.Thread.run(Unknown Source)

 

For some reason, fishing_spot is returning null. I'm not even 2 tiles from a fishing spot. And it's spelled correctly, with proper capitalization. I don't get why it's null.

first, i'd take juggles' recommendation and change the script name just to make sure. second, fishing spots are npcs, not objects.

  • Author
1 minute ago, Imateamcape said:

first, i'd take juggles' recommendation and change the script name just to make sure. second, fishing spots are npcs, not objects.

Already did change the name, going to take it step by step this time. Seems to be working better, and the Bolga Gold must be an ad. It's not trying to drop anything anymore.

try this just add the fishing Area location

 

public class Main extends Script {
	
	Area fishing_area = new Area(0, 0, 0, 0);


	private enum State {
		Fish, Bank, Wait
	};

	private State getState() {
		if (!getInventory().isFull())
			return State.Fish;
		if (getInventory().isFull())
			return State.Bank;
		return State.Wait;
	}
	
	@Override
	public int onLoop() throws InterruptedException {
		switch (getState()) {
		case Fish:
			if (!fishing_area.contains(myPlayer())) {
				walking.webWalk(fishing_area);
			}else{
				if (!myPlayer().isAnimating()) {
					NPC fish = getNpcs().closest("Fishing spot");
					if (fish !=null){
						fish.interact("Lure");
						new ConditionalSleep(5000) {
							@Override
							public boolean condition() throws InterruptedException {
								return myPlayer().isAnimating();
							}
						}.sleep();
					}
				}
			}
			break;
		case Bank:
			if (!Banks.CAMELOT.contains(myPlayer())) {
				walking.webWalk(Banks.CAMELOT);
			}else{
				if (!getBank().isOpen()) {
					getBank().open();
					new ConditionalSleep(5000) {
						@Override
						public boolean condition() throws InterruptedException {
							return getBank().isOpen();
						}
					}.sleep();
				}else{
					getBank().depositAllExcept("Fly fishing rod", "Feather");
				}
			}
			break;
		case Wait:
			break;
		
		}
		
		return 500;
	}

}

 

 

  • Author
26 minutes ago, Juggles said:

try this just add the fishing Area location

 

I appreciate the help for sure. I have no idea why the same script (I literally copy pasted, just used a different project name) worked and the other tried dropping everything. I also was under the incorrect assumption that Fishing Spots were Entities rather than NPCs. I'm still looking at finding all the basic info. I did set it up a little differently though, see below. Any advantages/disadvantages to the way you have it set up vs how I set it up? Also, anti-ban. Just looking around with the search a little, would this be suitable? (Look for doAntiBan) 

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;
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;

@ScriptManifest(author = "Engineer", info = "Fishin Script Yo", name = "Engineer Fishing", version = 0, logo = "")
public class Main extends Script {
	@Override
	public void onStart() {
		log("Welcome to My Fisher by Engineer.");
	}

	private enum State {
		WALK_BANK, WALK_FISHING, BANK, FISH
	};

	private State getState() {
		Area fishing_area = new Area(2714, 3535, 2731, 3523);

		if (getInventory().isFull()) {
			if (Banks.CAMELOT.contains(myPosition())) {
				return State.BANK;
			} else {
				return State.WALK_BANK;
			}
		} else {
			if (fishing_area.contains(myPosition())) {
				return State.FISH;
			}
			
			if (!getInventory().contains("Raw trout") && !getInventory().contains("Raw salmon")) {
				return State.WALK_FISHING;
			}
		}
		
		return null;
	}

	@Override
	public int onLoop() throws InterruptedException {
		switch (getState()) {
			case WALK_BANK:
				log("Walking to Bank");
				getWalking().webWalk(Banks.CAMELOT);
				break;
			case WALK_FISHING:
				log("Walking to fishing grounds");
				getWalking().webWalk(new Position(2723, 3530, 0));
				break;
			case BANK:
				log("Banking");
				if (!getBank().isOpen()) {
				    if (getBank().open()) {
				    	new Sleep(() -> getBank().isOpen(), 1000).sleep();
				    	getBank().depositAllExcept("Fly fishing rod", "Feather");
				    }
				}
				
				break;
			case FISH:
				log("Fishing");
				NPC fishing_spot = getNpcs().closest("Fishing spot");
				
				if (!myPlayer().isAnimating()) {
					if (fishing_spot != null) {
						if (fishing_spot.interact("Lure")) {     
							mouse.moveVerySlightly();
							
						    new ConditionalSleep(5000) {
						        public boolean condition() {
						            return myPlayer().isAnimating();
						        }
						     }.sleep();
						}
					}
				}

				break;
		default:
			sleep(random(500, 700));
			break;
		}
		
		return random(200, 300);
	}

	@Override
	public void onExit() {
		log("Thanks for running Engineer Fishing!");
	}
}

 

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.