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.

[Beginner] Trying to run simple miner, it wont even start?

Featured Replies

Hey :D It's me again :)

Have a problem with my miner, - tried writing it different from what I'm used to; Tried using private voids and then putting them into onLoop. What can I improve and what is making my script not runnable? :o  

public class LSCopperMiner extends Script {

    private Area miningArea = new Area( 3228, 3145, 3229, 3145);

    private void walking(){

        if (getInventory().isEmptyExcept("Bronze pickaxe","Iron pickaxe","Steel pickaxe",
                "Mithril pickaxe","Adamant pickaxe","Rune pickaxe" )
                && !miningArea.contains(myPosition())){

            log("Inventory is empty and miningArea does not contain my position, walking to mining area");
            getWalking().webWalk(miningArea);

        } else if(getInventory().isFull() && !Banks.LUMBRIDGE_UPPER.contains(myPosition())) {

            log("Inventory is full, walking to LBank");
            getWalking().webWalk(Banks.LUMBRIDGE_UPPER);
        }
    }

    private RS2Object copperRocks = getObjects().closest(7484,7453);

    private void levelUpWhile() {

        while (getDialogues().isPendingContinuation()){

            if(getDialogues().clickContinue()){

                log("Interacting with copperRocks again");
                copperRocks.interact("Mine");
            }
        }
    }

    private void mining() throws InterruptedException {

        if(copperRocks != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){

            log("Interacting with copperRocks");
            copperRocks.interact("Mine");

            log("Sleeping a bit before 'going afk'");
            sleep(random(1000,1400));

            log("Moving mouse outside of screen,'going afk'");
            getMouse().moveOutsideScreen();
        }
    }

    private void banking() throws  InterruptedException {

        RS2Object bankBooth = getObjects().closest("Bank booth");

        if(!getBank().isOpen() && bankBooth != null && Banks.LUMBRIDGE_UPPER.contains(myPosition())) {

            log("In LBank and Bank is not open, interacting with Bank");
            bankBooth.interact("Bank");

            log("Sleeping for 1.5-2.5 sec to avoid interacting with bank again");
            sleep(random(1500, 2500));
        }

        if(getBank().isOpen()) {

            log("Bank is open, depositing everything except pickaxes");
            getBank().depositAllExcept("Bronze pickaxe","Iron pickaxe","Steel pickaxe",
                                       "Mithril pickaxe","Adamant pickaxe","Rune pickaxe");
        }
    }

    @Override
    public int onLoop() throws InterruptedException {

        if(!miningArea.contains(myPosition()) || !Banks.LUMBRIDGE_UPPER.contains(myPosition())) {

            walking();
        }

        else if(miningArea.contains(myPosition())){

            levelUpWhile();
            mining();
            banking();
        }

        return 1000;
    }
}

Edited by t0r3

Also

following line 

    private RS2Object copperRocks = getObjects().closest(7484,7453);

Should be in your mining() method. 

private void mining() throws InterruptedException {

    RS2Object copperRocks = getObjects().closest(7484,7453);
        
         if(copperRocks != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){

            log("Interacting with copperRocks");
            copperRocks.interact("Mine");

            log("Sleeping a bit before 'going afk'");
            sleep(random(1000,1400));

            log("Moving mouse outside of screen,'going afk'");
            getMouse().moveOutsideScreen();
        }
    }

^^ now it will try to find copperRocks obj always when you run mining() method, not only at start of the script. 

  • Author
3 minutes ago, ThatGamerBlue said:

You got your


@ScriptManifest

annotation?

Yeah :)  I have the ScriptManifest up, able to locate it, click run and then it just doesnt do anything.

When I click the Start button after choosing my script nothing happens. It doesn't even shift from the green play button to pause and stop button options.. :o 

33 minutes ago, t0r3 said:

private RS2Object copperRocks = getObjects().closest(7484,7453);

This value needs to be refreshed every time you try to mine a new rock. Do this in every method that uses this variable.

  • Author
7 minutes ago, Xx pk xX said:

Also

following line 


    private RS2Object copperRocks = getObjects().closest(7484,7453);

Should be in your mining() method. 


private void mining() throws InterruptedException {

    RS2Object copperRocks = getObjects().closest(7484,7453);
        
         if(copperRocks != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){

            log("Interacting with copperRocks");
            copperRocks.interact("Mine");

            log("Sleeping a bit before 'going afk'");
            sleep(random(1000,1400));

            log("Moving mouse outside of screen,'going afk'");
            getMouse().moveOutsideScreen();
        }
    }

^^ now it will try to find copperRocks obj always when you run mining() method, not only at start of the script. 

Thanks :)

Ah, yeah I put all the way up there because I use it both in;

private void levelUpWhile() {

and,

private void mining() throws InterruptedException {

This is completely wrong?

Put in both methods now, for reference :D

2 minutes ago, Script Kid said:

This value needs to be refreshed every time you try to mine a new rock. Do this in every method that uses this variable.

Thanks! :D Yeah I realize this now :) hahah

Edited by t0r3

miningArea has only 2 tiles? Following condition probably won't run - my guess is that player is not in mining area. 

else if(miningArea.contains(myPosition())){

Just make mining area bigger. Also make sure that copperRocks id's are correct. Then it should run ?

  • Author
39 minutes ago, Xx pk xX said:

miningArea has only 2 tiles? Following condition probably won't run - my guess is that player is not in mining area. 


else if(miningArea.contains(myPosition())){

Just make mining area bigger. Also make sure that copperRocks id's are correct. Then it should run ?

Yeah :D

Ended up making this work;

@Override
public int onLoop() throws InterruptedException {

    if(!miningArea.contains(myPosition()) || !Banks.LUMBRIDGE_UPPER.contains(myPosition())) {

        walking();
    }

    if (miningArea.contains(myPosition())) {

        levelUpWhile();
        mining();
    }

    if (Banks.LUMBRIDGE_UPPER.contains(myPosition())){

        banking();
    }

    return 1000;
}

Tried putting 

else 

in front of

if (miningArea.contains(myPosition()))

Why won't this work?

 

-------------------------------------------------------------------------------------------------------------------------------------

 

Even though, - could just this work? The conditions for the different methods are already set in each one. Am I wrong? :o 

@Override
public int onLoop() throws InterruptedException {

    if(myPlayer.exists()) {

        walking();
        levelUpWhile();
        mining();
        banking();
    }

    return 1000;
}

Thanks for being so helpful :) :) I know I'm asking many questions haha :D getting really into it

Edited by t0r3

Quote

Even though, - could just this work? The conditions for the different methods are already set in each one. Am I wrong? :o 


@Override
public int onLoop() throws InterruptedException {

    if(myPlayer.exists()) {

        walking();
        levelUpWhile();
        mining();
        banking();
    }

    return 1000;
}

Thanks for being so helpful :) :) I know I'm asking many questions haha :D getting really into it

That should work so long as all of your conditionals are correct. Easiest way to test that would be to just do it. The main things you have to ask yourself is calling any of those other methods while another one is happening going to screw with what your script tries to do? For instance if you call levelUpWhile() and the script is actually banking etc..

 

As for your second question regarding why sticking else in front of that if statement doesn't work i'm not sure why it isn't working, as logically it should as long as it's formatted like this:

 

@Override
public int onLoop() throws InterruptedException {

    if(!miningArea.contains(myPosition()) || !Banks.LUMBRIDGE_UPPER.contains(myPosition())) {
        walking();
    } else if (miningArea.contains(myPosition())) {
        levelUpWhile();
        mining();
    } else if (Banks.LUMBRIDGE_UPPER.contains(myPosition())){
        banking();
    }

    return 1000;
}

 

Edited by Nebulae

I haven't read all of the above comments, but the reason why your script wouldn't load is because you were trying to create your RSObject variable outside of the loop, where the script wouldn't have loaded properly. This was causing it to 'crash'. :) 

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.