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.

Detecting that a rock has been mined?

Featured Replies

I finished figuring out how to determine which of the same kind of rocks my bot is mining (eg. determine which of the two iron rocks I'm currently mining) but I currently can't get the bot to detect if the rock has been mined or not.

I'm using a check with the depleted rock ID, but its not picking up on it. I know its better to use color as a check for mining, but I'm wanting to use IDs for the meantime while I finish writing everything else and then deal with the color checks. 

Can I use IDs as a check? I've tried searching for source codes to see how other people have dealt with it, but couldn't find any.

 

1 hour ago, Dab in a Lab said:

I finished figuring out how to determine which of the same kind of rocks my bot is mining (eg. determine which of the two iron rocks I'm currently mining) but I currently can't get the bot to detect if the rock has been mined or not.

I'm using a check with the depleted rock ID, but its not picking up on it. I know its better to use color as a check for mining, but I'm wanting to use IDs for the meantime while I finish writing everything else and then deal with the color checks. 

Can I use IDs as a check? I've tried searching for source codes to see how other people have dealt with it, but couldn't find any.

Lend me a account and I can post an open source snippet for everyone

  • Author
32 minutes ago, Chris said:

obj.getModifiedColours() == null

Lend me a account and I can post an open source snippet for everyone

Just pmed account info

1 hour ago, Dab in a Lab said:

I finished figuring out how to determine which of the same kind of rocks my bot is mining (eg. determine which of the two iron rocks I'm currently mining) but I currently can't get the bot to detect if the rock has been mined or not.

I'm using a check with the depleted rock ID, but its not picking up on it. I know its better to use color as a check for mining, but I'm wanting to use IDs for the meantime while I finish writing everything else and then deal with the color checks. 

Can I use IDs as a check? I've tried searching for source codes to see how other people have dealt with it, but couldn't find any.

This is what I have come up with

two_ore_spawn area

ylEzWb8.png

    private Area two_ore_spawn = new Area(3175, 3366, 3175, 3368);
    private boolean newRock;
	//If we stopped animating OR newRock is TRUE
        if (!myPlayer().isAnimating() || newRock){
            //Object filter for: hasOre AND inside the specified area
            RS2Object rock = getObjects().closest(obj -> Rock.IRON.hasOre(obj) && two_ore_spawn.contains(obj.getPosition()));

            //If rock type exists && we clicked it
            if (rock != null && rock.interact("Mine")){
                //Set newRock to FALSE if we have just clicked it!
                newRock = false;
                log("Clicked on: " + rock.getName() + " " + rock.getPosition());
                //Sleep until condition evaluates to true for 5 seconds and looping the condition every 1.5 seconds
                if (new ConditionalSleep(5000, 1500) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return !rock.exists();
                    }
                }.sleep()){
                    log("Conditional sleep evaluated to true!");
                    //If the conditional sleep evaluated true then we set newRock to TRUE
                    newRock = true;
                }
            }
        }

 

Explv's Snippet Data
 

import org.osbot.rs07.api.model.Entity;

public enum Rock {
    CLAY(new short[]{6705}),
    COPPER(new short[]{4645, 4510}),
    TIN(new short[]{53}),
    IRON(new short[]{2576}),
    SILVER(new short[]{74}),
    COAL(new short[]{10508}),
    GOLD(new short[]{8885}),
    MITHRIL(new short[]{-22239}),
    ADAMANTITE(new short[]{21662}),
    RUNITE(new short[]{-31437});

    private short[] colours;

    Rock(final short[] colours) {
        this.colours = colours;
    }

    public boolean hasOre(final Entity rockEntity) {
        if (rockEntity.getDefinition() == null) {
            return false;
        }

        short[] colours = rockEntity.getDefinition().getModifiedModelColors();

        if (colours == null) {
            return false;
        }

        for (short rockColour : this.colours) {
            for (short entityColour : colours) {
                if (rockColour == entityColour) {
                    return true;
                }
            }
        }
        return false;
    }
}

 

edit: nvm Chris explained it and posted code.

Edited by IDontEB

5 hours ago, Dab in a Lab said:

I finished figuring out how to determine which of the same kind of rocks my bot is mining (eg. determine which of the two iron rocks I'm currently mining) but I currently can't get the bot to detect if the rock has been mined or not.

I'm using a check with the depleted rock ID, but its not picking up on it. I know its better to use color as a check for mining, but I'm wanting to use IDs for the meantime while I finish writing everything else and then deal with the color checks. 

Can I use IDs as a check? I've tried searching for source codes to see how other people have dealt with it, but couldn't find any.

From your explanation, it sounds like you're expecting your RS2Object instance (from before depletion) to change ID, which it never will. You will have to grab the new RS2Object instance, as the depleted rock is generally speaking a new different object.
As an alternative to checking the depletion ID, you could check if your non-depleted object instance has stopped existing with the exists() method.

Edited by FrostBug

  • Author
7 hours ago, FrostBug said:

From your explanation, it sounds like you're expecting your RS2Object instance (from before depletion) to change ID, which it never will. You will have to grab the new RS2Object instance, as the depleted rock is generally speaking a new different object.
As an alternative to checking the depletion ID, you could check if your non-depleted object instance has stopped existing with the exists() method.

Ya, that’s exactly what I was doing. I was relying on my script to pick up on the new rock ID from the one instance.

I’ve got everything working great now though with Chris’s help.

Create an account or sign in to comment

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.