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.

Problem with my mining script

Featured Replies

So I accidentally deleted my broken mining script and am trying to re-create it from memory, and so far so good. However I am trying to check the color of the rock before I mine it and I am missing something.

 

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

        private final short COLOUR;

        Rock(final int COLOUR) {
            this.COLOUR = (short) COLOUR;
        }

        public boolean hasOre(final RS2Object object) {
            if (object == null || object.getDefinition().getModifiedModelColors() == null || !"Rocks".equals(object.getName())) {
                return false;
            }

            for (final short colour : object.getDefinition().getModifiedModelColors()) {
                if (colour == this.COLOUR) {
                    return true;
                }
            }
            return false;
        }
    }

    public void Minesomething() throws InterruptedException {
 
        goldRock = getObjects().closest( obj -> Rock.GOLD.hasOre(obj));
        if (goldRock != null && goldRock.interact("Mine")) {
            new Sleep(() -> isAnimating() || !Rock.GOLD.hasOre(goldRock), 10000).sleep();
        }

    }

 

That is the code I am having trouble with, It says can not resolve symbol goldRock. And I cant remember how I had it in my original working script. Any pointers?

 

Edited by loopback
typo

         if (object == null || object.getDefinition().getModifiedModelColors() == null || !"Rocks".equals(object.getName())) {

 

Should be Rock?

You haven't declared a goldRock variable. You're trying to reference it but it doesn't exist, thus the "Symbol cannot be found" error.

What you need to do is declare a variable of the same type as the return value from getObjects#closest. The return type is RS2Object, so the code should look like:
RS2Object goldRock = getObjects().closest( obj -> Rock.GOLD.hasOre(obj));

Edited by Easy

  • Author
18 minutes ago, Easy said:

You haven't declared a goldRock variable. You're trying to reference it but it doesn't exist, thus the "Symbol cannot be found" error.

What you need to do is declare a variable of the same type as the return value from getObjects#closest. The return type is RS2Object, so the code should look like:
RS2Object goldRock = getObjects().closest( obj -> Rock.GOLD.hasOre(obj));

This is it! Thank you I knew it was something obvious. This is what I get for cleaning my hard drive at 2am then trying to recreate something from memory. Thanks

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.