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 with multiple files

Featured Replies

I am trying to create a larger script than usual, so I want to use multiple files for it.

 

Now I have the main script that starts up, but I have to use the methods of "MethodProvider" in the OSBot API in the other class too. Something like:

 

MainScript.java

private DoWalkPath path;

@Override
public void onStart() {
   path = new DoWalkPath(); // This is just an example name, I don't want the other class just to walk...
}

@Override
public int onLoop() throws InterruptedException {
    switch (state) {
        case WALKING_TO_BANK:
        path.walk(); // This is what I want
        break;
    }
    return 3;
}

DoWalkPath.java

public void walk() {
    openTab(Tabs.Magic);
    selectInterfaceOption(271, 23, "Cast"); // Teleport or something
    sleep(random(5000, 6000)); // Wait for teleport
    walk(Position); // Walk from there
}

Now I can't use "walk()" as I don't have access to the MethodProvider in that other class.

 

I tried extending the MethodProvider, but I every value is null (client etc).

Edited by SXForce

You have to pass object that uses Method provider, Script  class extends it so you can use it. Make a constructor in you DoWalkPath class which takes Script as a parameter something like this

public DoWalkPath(Script script) {
     this.script = script;
}

and to initiate it in the main calss just simplu make an DoWalkPath and pass to it the parameter script(Main class)

public DoWalkPath walk = new DoWalkPath(this);

Hope this helps.

  • Author

You have to pass object that uses Method provider, Script  class extends it so you can use it. Make a constructor in you DoWalkPath class which takes Script as a parameter something like this

public DoWalkPath(Script script) {
     this.script = script;
}

and to initiate it in the main calss just simplu make an DoWalkPath and pass to it the parameter script(Main class)

public DoWalkPath walk = new DoWalkPath(this);

Hope this helps.

 

Yeah, just did this and it works. Thanks for the answer.

 

Isn't there another way where i dont have to pass the entire class? :P

Guest
This topic is now closed to further replies.

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.