Jump to content

ExchangeContext and getBot?


Recommended Posts

Posted (edited)

I am looking at this script to try and understand the API: https://github.com/Explv/Tutorial-Island

I used the documentation and think I get it all now, but only part I cant find an answer to on the forums or really understand from reading the API documentation is exchangeContext(getBot()).

The main onLoop calls someSection.onLoop() on various sections, each section extends MethodProvider and is its own class.

In the onStart() part it calls someSection.exchangeContext(getBot()) on each of the sections.

My question is, what does exchangeContext() do?

The API says getBot() gets the bot instance, is that the individual bot if multiple are running in the osbot client, or am I misunderstanding?

Appreciate any help

 

public final class TutorialIsland extends Script {
    public static final String VERSION = "v6.2";

    private final TutorialSection rsGuideSection = new RuneScapeGuideSection();
    private final TutorialSection survivalSection = new SurvivalSection();
    private final TutorialSection cookingSection = new CookingSection();
    private final TutorialSection questSection = new QuestSection();
    private final TutorialSection miningSection = new MiningSection();
    private final TutorialSection fightingSection = new FightingSection();
    private final TutorialSection bankSection = new BankSection();
    private final TutorialSection priestSection = new PriestSection();
    private final TutorialSection wizardSection = new WizardSection();

    @Override
    public void onStart() {
        rsGuideSection.exchangeContext(getBot());
        survivalSection.exchangeContext(getBot());
        cookingSection.exchangeContext(getBot());
        questSection.exchangeContext(getBot());
        miningSection.exchangeContext(getBot());
        fightingSection.exchangeContext(getBot());
        bankSection.exchangeContext(getBot());
        priestSection.exchangeContext(getBot());
        wizardSection.exchangeContext(getBot());

        Sleep.sleepUntil(() -> getClient().isLoggedIn() && myPlayer().isVisible() && myPlayer().isOnScreen(), 6000, 500);
    }

    @Override
    public final int onLoop() throws InterruptedException {
        if (isTutorialIslandCompleted()) {
            stop(true);
            return 0;
        }

        switch (getTutorialSection()) {
            case 0:
            case 1:
                rsGuideSection.onLoop();
            .
            .
            .

 

Edited by Kasperil

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...