Jump to content

Using Multiple Classes


Recommended Posts

Posted

the simplest way to do this is to extend MethodProvider:

class MyScriptStep extends MethodProvider {
    public void run() {
        getObjects().getAll()...; // Use OSBot API as you would in main script class
    }
}

Then in your script you would do

class MyScript extends Script {
    // Define the MyScriptStep object
    private MyScriptStep scriptStep = new MyScriptStep();
    // ...
    @Override
    public void onStart() {
        scriptStep.exchangeContext(getBot()); // Configure the MethodProvider to use this bot
    }
    // ...
    public int onLoop() {
        if (someCondition) {
            scriptStep.run(); // Run the step
        }
    }
}

 

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...