Jump to content

ExchangeContext and getBot?


Kasperil

Recommended Posts

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