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.

Conditional Sleep while mining NullPointerException

Featured Replies

Sooo.... I've spent a while away from making scripts but since I finally have time to work on some stuff, I've decided to make a simple motherload miner 

The code is mostly done and I'm planning to release it at some point, but I only have one problem....

                RS2Object oreDeposit = api.getObjects().closest("Ore vein");
                String objectName = oreDeposit.getName();
                int objectModelID = oreDeposit.getId();
                if(api.getMap().canReach(oreDeposit)) {
                    oreDeposit.interact("Mine");
                    api.log("Waiting to be done mining");
                    new ConditionalSleep(6000, 8000) {
                        @Override
                        public boolean condition() {
                            return !api.getObjects().closest(objectModelID).getName().equals("Ore vein");
                        }
                    }.sleep();

I've made this simple conditional sleep, which checks the model ID of the previously saved object, and compares it to what it expected to be there while the ore is mineable, 

All is good while it is still called 'ore vein', but after it depletes, it starts freaking out (I have to force close it) with a NullPointerException

 

I've checked the modeID before and after it has depleted, and it does not change, therefore I am here to see what you guys suggest! Or I accept being absolutely retarded (it do be like that sometimes)

  • Author
2 hours ago, HeyImJamie said:

You need to null check. The NPE thrown will direct you to where. :)

 

 

I've added check for it and now the error is gone???????? No output or anything even when using 

 catch (NullPointerException e) {
                    api.log(e.getMessage());
                }

Decided to split two functions and now it works :/ 

I still have no idea how I fixed it 😧

Edited by Protoprize

RS2Object oreDeposit = getObjects().closest("Ore vein");
        String objectName = oreDeposit.getName();
        int objectModelID = oreDeposit.getId();
        if(oreDeposit != null && getMap().canReach(oreDeposit)) {
            oreDeposit.interact("Mine");
            log("Waiting to be done mining");
            new ConditionalSleep(6000, 8000) {
                @Override
                public boolean condition() {
                    return getObjects().closest(objectModelID) != null && getObjects().closest(objectModelID).getName().equals("Ore vein");
                }
            }.sleep();
        }

 

  • 2 years later...
On 12/15/2019 at 10:33 AM, FuryShark said:
RS2Object oreDeposit = getObjects().closest("Ore vein");
        String objectName = oreDeposit.getName();
        int objectModelID = oreDeposit.getId();
        if(oreDeposit != null && getMap().canReach(oreDeposit)) {
            oreDeposit.interact("Mine");
            log("Waiting to be done mining");
            new ConditionalSleep(6000, 8000) {
                @Override
                public boolean condition() {
                    return getObjects().closest(objectModelID) != null && getObjects().closest(objectModelID).getName().equals("Ore vein");
                }
            }.sleep();
        }

 

Tried this and it still spam clicks the ore vein :(

Untitled.png

11 hours ago, Gunman said:

Try using !ore.exists()
I don't know if this will work or not, depends on how OSBot does that method

Still clicks the ore it's already mining :( 

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.