Jump to content

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


Recommended Posts

Posted

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.

Posted
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

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