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.

Call other script/class from inside script?

Featured Replies

Having an issue where it just crashes the bot.

Just trying to get it set up, so there isn't much code, but the gist is like this:

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import skills.Fishing;

@ScriptManifest(name = "Testing", author = "Aeikonic", info = "Just a test", version = 0.1, logo = "")
public class testBot extends Script {

    protected Fishing fish;

    @Override
    public final int onLoop() throws InterruptedException {
        fish.goFishing();
        return random(150, 200);
    }
}

The fishing script is declared like this:

public abstract class Fishing extends Script {

Is that the issue or is it how I'm calling it in the upper level script? The fishing bot works when turned into a normal script. How do I call it / activate it from another script?

 

EDIT:

 

Updated Fishing to an Event:

public class Fishing extends Event {

Calling it like this:

protected Fishing fish = new Fishing();

@Override
public final int onLoop() throws InterruptedException {
    fish.execute();
    return random(150, 200);
}

Getting a NullPointerException though which says it's at this line:

private boolean canFish() {
    return getInventory().contains("Small fishing net");
}

Wasn't getting it when not pulling the script in as an event though, so a bit confused... not sure if I'm still pulling it in wrong or if running it as an event means I need to recode parts of it.

 

EDIT AGAIN:

Got it, had to run execute(fish);

:)

Edited by aeikonic

I'd recommend following some Java tutorials, in your first example you didn't even construct an instance of your Fishing class. You also made your Fishing class abstract, which means it cannot be instantiated directly.

Only your main script class should extend Script.

If you want other classes to be able to access the API, either pass MethodProvider as a constructor arg, or make your other class extend MethodProvider and exchange context.

See section 5 of https://osbot.org/forum/topic/115124-explvs-scripting-101/

 

 

Edited by Explv

  • Author

Yeah the IDE was throwing me for a loop because it told me if I didn't have onLoop in Fishing (when it was extending Script) I'd have to make it abstract, which then told me I couldn't instantiate it on the upper level script. Had me all confused but figured it out. Got a few basic scripts working now though :D

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.