Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Exception error help


    tsremix777

    Recommended Posts

    First, I would recommend null checking your rocks in your filter like so:

    GameObject rock1 = getGameObjects().closest(GameObject -> GameObject != null && (GameObject.getID() == 7487) && GameObject.distance(getLocalPlayer()) < 3);			
    GameObject rock2 = getGameObjects().closest(GameObject -> GameObject != null && (GameObject.getID() == 7454) && GameObject.distance(getLocalPlayer()) < 3); 

    Edit: It occured to me that you might also want to null check in your if statement, in case another player mines the rock before you interact with it.

    //filters up here
    if (rock1 != null && rock1.isOnScreen()) { //isOnScreen() might be isVisible() instead, I can't remember - however, this is redundant since your filter only looks for rocks a max of 2 tiles away
       rock1.interact();
    }
    

    For future reference, if you have a script that has to throw NPEs (a mining script shouldn't):

     

    For example, I have a script that changes location randomly and throws NPEs all over the place. Use try/catch blocks when NPEs are unavoidable.

    //a way to gracefully handle exceptions
    try {
         //put your code that throws the exception here
    } catch (NullPointerException e) {
         log("Caught (" + String.valueOf(e) + ")"); //delete this after testing
         break; //or some other exit condition check if the NPE is thrown in a loop, you can also just leave the catch block blank, or sleep
    }
    

    Let me know if you need more help.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.