Jump to content

Using Multiple Classes


Sebastian

Recommended Posts

Hi everyone,

I need to know how to use multiple classes. I'm creating a little quester. 

I have a main class with the onloop() and i have a class for the cooks assistent quest called cookassistent. I want to script the whole procedure of cooks assistent in that class. How would i do that?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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