Kasperil Posted December 24, 2019 Share Posted December 24, 2019 (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 December 24, 2019 by Kasperil Quote Link to comment Share on other sites More sharing options...
Charlotte Posted December 24, 2019 Share Posted December 24, 2019 1 Quote Link to comment Share on other sites More sharing options...
Kasperil Posted December 24, 2019 Author Share Posted December 24, 2019 Thank you for the quick reply. So, exchangeContext is used to pass/copy the bot reference to other classes that then use their own instance of the methodprovider on that bot, allowing either class to operate on the same "bot instance"? Quote Link to comment Share on other sites More sharing options...