Jump to content

[Snippet request] Conditional sleep until login and welcome screen are completed


Normangorman

Recommended Posts

Does anyone know how to implement this? Scripts seem to get a couple of 'onLoop's off in between the client solving the login screen event and detecting the welcome screen event. The welcome screen seems to cause weird bugs in the initial part of a script if you need to set up config based on what the player can see.

Link to comment
Share on other sites

if (!getClient().isLoggedIn()) {

    //Conditional sleep until getClient().isLoggedIn()

}

Edit: Just wanna add that a conditional sleep may not be the best for this, eg if it's in onloop you can just do:

if (!getClient().isLoggedIn()) {
    return 1000;
}

 

 

You could sleep when bot.getRandomExecutor().forEvent(RandomEvent.WELCOME_SOLVER).shouldActivate() == true, assuming the widget is actually visible when this happens.

 

Thanks for your help. By combining both of these checks I was able to create a snippet that solves the problem. Note that RandomSolver#shouldActivate crashes with a NullPointerException if you call it for the WELCOME_SOLVER event when you're already logged in. This is probably a bug - and is the reason for the try - catch below.

if (!doneOnReady) {
            boolean loggedIn = bot.getClient().isLoggedIn();
            boolean inWelcomeScreen;
            try {
                inWelcomeScreen = bot.getRandomExecutor().forEvent(RandomEvent.WELCOME_SOLVER).shouldActivate();
            }
            catch (NullPointerException e) {
                inWelcomeScreen = false;
            }

            if (loggedIn && inWelcomeScreen == false) {
                onReady();
                doneOnReady = true;
            }
            else {
                return 100;
            }
        }
  • 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...