Jump to content

Not sleeping


zulfikar

Recommended Posts

private void Mine() {
        for(Position rock : rockList) {
            for (RS2Object r : bot.getMethods().objects.filter(main::isRock)) {
                if (r.isVisible() && r.getPosition().equals(rock)) {
                    if (!isMined(r) && r !=null && rock.interact(bot, "Mine")) {
                        Sleep.sleepUntil(() -> myPlayer().isAnimating() || isMined(r), 5000);
                    }
                }
            }
        }
    }

I have this and it doesn't seem to stop when mining. It keeps clicking between the rocks in my rockList. I can't seem to figure out the issue. This method is called from onLoop. I'm using Explv's sleep class. I tried using normal conditional sleep without the class and sleep itself, but it still continues clicking between the rocks without waiting.

import org.osbot.rs07.utility.ConditionalSleep;
import java.util.function.BooleanSupplier;

public final class Sleep extends ConditionalSleep {

    private final BooleanSupplier condition;

    public Sleep(final BooleanSupplier condition, final int timeout) {
        super(timeout);
        this.condition = condition;
    }

    public Sleep(final BooleanSupplier condition, final int timeout, final int interval) {
        super(timeout, interval);
        this.condition = condition;
    }

    @Override
    public final boolean condition() throws InterruptedException {
        return condition.getAsBoolean();
    }

    public static boolean sleepUntil(final BooleanSupplier condition, final int timeout) {
        return new Sleep(condition, timeout).sleep();
    }

    public static boolean sleepUntil(final BooleanSupplier condition, final int timeout, final int interval) {
        return new Sleep(condition, timeout, interval).sleep();
    }
}

 

Link to comment
Share on other sites

Sleep.sleepUntil(() -> myPlayer().isAnimating() || isMined(r), 5000);

One part of your condition to stop sleeping is when your player begins to/is doing something, rather than when it stops doing something. So as soon as it starts mining it breaks the sleep and starts looking for another rock.

Edited by luciuspragg
Link to comment
Share on other sites

32 minutes ago, luciuspragg said:

Sleep.sleepUntil(() -> myPlayer().isAnimating() || isMined(r), 5000);

One part of your condition to stop sleeping is when your player begins to/is doing something, rather than when it stops doing something. So as soon as it starts mining it breaks the sleep and starts looking for another rock.

I fixed it. It was this and then moving the interact out of the if statement


Thanks guys.

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