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.

multiple classes?

Featured Replies

Can I use multiple classes for a script? What I essentially want to do it do a task until a condition is met, and then perform a different task, within a different java class in the same script.

is this possible? and if so, how do I switch to the next class within my code? 

Sorry about the question, i'm a java noob xD

  • Author
3 minutes ago, ProjectPact said:

You should try Script Factory :) 

I already own script factory, I'm trying to start writing my own scripts properly. Just wondering if what I asked was possible, that's all 

  • Author
8 minutes ago, Gunman said:

Money hungry Project didn't answer the question. Answer is yes you can. Read everything in OOP 1 & 2 and I think that would be enough to start messing around with multiple classes.

EDIT: Forgot to link the material https://www.programiz.com/java-programming

Thank you dude!

  • Author

for osbot, would I use one class to control the script, and use the onLoop methods from the other classes?

 

heres the 2 ways to do mutiple classes. I know there are more but these are simple.

Type 1:

public class Something extends MethodProvider {
	public void doSomething(){
		getBank().Open()
	}
}

in your main script do this

Something something = new Something()

void onStart(){
        something.exchangeContext(getBot());
}

Type 2:

public class Something{
	MethodProvider mp;
	public Something(MethodProvider mp){
		this.mp =mp
	}
	public void doSomething(){
		mp.getBank().Open()
	}

}

 

REad your question wrong this is something you like

Just warning scripts write like this are hard to debug and pron to errors

 

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

public abstract  class Test extends MethodProvider {
    abstract void doSomething();
    abstract  boolean done();
    abstract Test next();


}


public   class OpenBank extends Test {


    @Override
    void doSomething() {
        try {
            this.getBank().open();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @Override
    boolean done() {
        return getBank().isOpen();
    }

    @Override
    Test next() {
        return new CloseBank();
    }
}
public   class CloseBank extends Test {


    @Override
    void doSomething() {

            this.getBank().close();

    }

    @Override
    boolean done() {
        return !getBank().isOpen();
    }

    @Override
    Test next() {
        return new OpenBank();
    }
}

@ScriptManifest(author = "Bacon", name = "0", info = "Runtime bots", version = 0.0, logo = "")

public class ScriptWithtasks extends Script {
    Test curent = new OpenBank();

    @Override
    public void onStart() throws InterruptedException {
        curent.exchangeContext(getBot());

    }

    @Override
    public int onLoop() throws InterruptedException {
        curent.doSomething();

        if (curent.done()){
            curent = curent.next();
            curent.exchangeContext(getBot());
        }

        return 0;
    }
}

 

 

 

 

Irl ProjectPact be like...

Random person: Someone call 911.

ProjectPact: You should try Script Factory :) 

 

 

 

 

 

Edited by Nbacon

4 hours ago, Gunman said:

Money hungry Project didn't answer the question. Answer is yes you can. Read everything in OOP 1 & 2 and I think that would be enough to start messing around with multiple classes.

EDIT: Forgot to link the material https://www.programiz.com/java-programming

Or trying to help someone with a tool that is designed to develop scripts with no programming knowledge. 

47 minutes ago, Malcolm said:

But learning Java is more fulfilling :doge:

Biden himself has spoken.

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.