Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Issues with ConditionalSleep

Featured Replies

So, as most people posting in this section seem to be, I'm pretty new.

In my attempt to make my first script, I combined the 'Tea Stealer' tutorial (Top post of this section) with some information from Explv's tutorial in order to attempt to make a basic woodcutting script. My basic edits to 'Tea stealer' went down without a htich, as the script comfortably locates trees and selects 'Chop down'. However, the issue is that it just spam clicks them which I estimate would take 12 minutes to get me banned.

As such, I found Explv's tutorial which included information on 'ConditionalSleep' which prevents this. So I copy&pasted his sleep code into the seemingly-appropriate section and... it didn't do anything. The script just carries on exactly like this snippet of code doesn't exist. 

 

Quote

    @Override
    public int onLoop() throws InterruptedException {
        switch (getState()) {
        case STEAL:
            final RS2Object tree = getObjects().closest("Tree");
            if (tree != null && tree.interact("Chop down")) {
                new ConditionalSleep(5000) {
                    @Override
                    public boolean condition() {
                        return myPlayer().isAnimating() || !tree.exists();
                    }
                }.sleep();
            }                        
            break;
        case DROP:
            inventory.dropAll();
            break;
        case WAIT:
            sleep(random(500, 700));
            break;
        }
        return random(200, 300);
    }
 

That's the affected part of my code, the onLoop bit.

Can anyone see what the issue is? I'll also include my imports incase that could be an issue:

 

Quote

import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.utility.ConditionalSleep;

import java.awt.*;

 

 Cheers for any assistance.

 

Also, does anyone have any good ways to get into this? I've completed the CodeAcadamy course on JavaScript as well as looked extensively at both tutorials previously mentioned and a lot of the time I'm struggling to make the links. I understand the core language as a result of the CodeAcadamy course so I know what if statements and all that is, but there's still so much I just don't and there doesn't really seem to be anywhere that I can bridge the gap. For example, I don't know what public void, private void, the difference between them, what void even if, what 'final' means (For example, see onLoop code under 'Case steal'.

 

 

Works as intended.

you are calling

isAnimating()

which returns true once you start the tree chop animation

it will stop the conditional sleep once it returns true.

What you need is a logic check.

if (!isAnimating())
    chopTree();

 

  • Author
5 minutes ago, Chris said:

Works as intended.

you are calling


isAnimating()

which returns true once you start the tree chop animation

it will stop the conditional sleep once it returns true.

What you need is a logic check.


if (!isAnimating())
    chopTree();

 

Ah that seems simple enough,

Basically what's happening is the sleep is ending whenever I'm in an animation since that's what it's set to.

It should be !isAnimating so that the sleep ends when the player is not animating. 

Cheers!

Edited by A Cool Lad

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.