Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • How to SleepUntil not in animation for at least X amount of time


    Verify
     Share

    Recommended Posts

    Hi, newbie scripter here.

    I was wondering if there is any ways to get out of sleep only when the condition persists for X amount of time.

    For example, if 

    sleepUntil(()->!getLocalPlayer().isAnimating(), 5000);

    is used, then sleep breaks every time the crafting animation stops. I would like it to stop sleeping when the player is idle for 4 seconds uninterrupted for example.

    Link to comment
    Share on other sites

    Hey, to answer your question, you can do something like this to sleep until it has been 4 seconds since your character previously animated with a timeout of 30 seconds.

    final long[] lastAnimated = { System.currentTimeMillis() };
    sleepUntil(() -> {
        if (getLocalPlayer().isAnimating())
            lastAnimated[0] = System.currentTimeMillis();
        return System.currentTimeMillis() - lastAnimated[0] >= 4000;
    }, 30000);

    However, I've hardly ever had to use anything like this. Are you sure this wouldn't be sufficient for your needs?

    sleepUntil(() -> getDialogues().inDialogue() || !getInventory().containsAll(REQUIRED_ITEMS_HERE), 30000);

    This way your script would continue either after 30 seconds or when you're in dialogue (level up, for example) or your character no longer has the required items in inventory.

    Link to comment
    Share on other sites

    Ty, it's exactly what I needed! I have some specific actions that can't rely on inventory checks so that's why I wanted some kind of catch all method to detect when actual clicks are needed.

    Link to comment
    Share on other sites

    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
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.