Jump to content

Neku's Potato Picker.


Neku

Recommended Posts

Ever wanted to become your own french fry king? 
Well i've brought a Potato picker due to the current SDN version being broken and killing my personal bot farm :(

Hope you guys enjoy!
Any feedback would be appreciated

Also thanks to @Malcolm_OS for assisting me with a very dumb error!

 

TODO:
PAINT ----- DONE
LOGO

GP Per Hour----- IN PROGRESS
TIMER ----- IN PROGRESS
Mule Support

 


import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.*;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;
import static org.osbot.rs07.api.map.constants.Banks.DRAYNOR;


@ScriptManifest(author = "Neku", info = "Potato Picker", name = "NekuPicker", logo = "", version = 1.0)
public class Main extends Script {

    @Override
    public void onStart() throws InterruptedException {
        log("Welcome to NekuPicker I hope you Enjoy");
        log("Starting Script Please Wait....");

    }

    @Override
    public int onLoop() throws InterruptedException {
        Area Field = new Area(3155, 3290, 3140, 3268);
        Area Pregate = new Area(3142, 3295, 3148, 3292);
        Area Postgate = new Area(3144, 3291, 3147, 3289);
        Area BANKS [] = {Banks.DRAYNOR};
        Entity Potato = objects.closest("Potato");
        Entity Gate = objects.closest("Gate");


        if (!getInventory().isFull()) { //If my inventory is empty
            if (!Field.contains(myPlayer())) { //If Player isn't in the Field Walk to Gate
                log("Started WebWalking");
                getWalking().webWalk(Pregate);
                Gate.interact("Open");
                log("Opening Gate");
                getWalking().webWalk(Field);

            } else { // If player is in the field Start Picking
                if (Potato != null) ;
                Potato.interact("Pick");
                new ConditionalSleep(750, 500) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return myPlayer().isAnimating() && myPlayer().isMoving();
                    }
                }.sleep();

                return 600;
            }

        } else if (!Banks.DRAYNOR.contains(myPlayer())){ //If you aren't inside the bank
            getWalking().webWalk(DRAYNOR);
            log("Web walking to Bank");
            if (!getBank().isOpen()){
                getBank().open();
                new ConditionalSleep(2000,500){
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getBank().isOpen();
                    }


                }.sleep();
                getBank().depositAll();
                new ConditionalSleep(1000,500) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getInventory().isEmpty();
                    }
                }.sleep();

                getBank().close();
                new ConditionalSleep(1500,500) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return !getBank().isOpen();
                    }
                }.sleep();
            }
        }
        return 0;
    }
 }

 

Edited by Neku
  • Like 3
Link to comment
Share on other sites

4 hours ago, Neku said:

Yeah it is, any tips?

Also there is a slight bug with banking that I need to sort out ?

Yeah I've got some tips for you :)

Area Field = new Area(3155, 3290, 3140, 3268);
Area Pregate = new Area(3142, 3295, 3148, 3292);
Area Postgate = new Area(3144, 3291, 3147, 3289);
//Area BANKS[] = {Banks.DRAYNOR}; PLEASE TAKE NOT THAT THIS IS WRONG
Area[] BANKS = {Banks.DRAYNOR};

Should be outside of the onLoop() and should be private static final. Also you're not following Java name conventions. Also look into OOP, http://www.ntu.edu.sg/home/ehchua/programming/java/J3a_OOPBasics.html.

Besides, you could make an enum with the States the script is in, and run a task based on that.

Edited by ManOfMen
Link to comment
Share on other sites

19 hours ago, Malcolm_OS said:

Hey man! 

You have to start somewhere right?!

I wrote a few simple scripts just like this to get used to the API. Once I felt confident I moved on to an actual project. My Tutorial Island script to be exact. 

It is soo satisfying to see your own brain put out onto a script with your own logic of how to do something and the computer operates it in your own unique way.

Sure, to anyone the bot looks like it's doing the same thing, cutting a tree, picking a potato, but the way the computer is receiving that information can be completely different.

 

Also like @H0rn said, there is a code function that we can use to make our code appear all nice like this:

7d5410693a2c30e89367ed3cb1bf2ca0.png
 


import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.*;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;
import static org.osbot.rs07.api.map.constants.Banks.DRAYNOR;


@ScriptManifest(author = "Neku", info = "Potato Picker", name = "NekuPicker", logo = "", version = 1.0)
public class Main extends Script {

    @Override
    public void onStart() throws InterruptedException {
        log("Welcome to NekuPicker I hope you Enjoy");
        log("Starting Script Please Wait....");

    }

    @Override
    public int onLoop() throws InterruptedException {
        Area Field = new Area(3155, 3290, 3140, 3268);
        Area Pregate = new Area(3142, 3295, 3148, 3292);
        Area Postgate = new Area(3144, 3291, 3147, 3289);
        Area BANKS [] = {Banks.DRAYNOR};
        Entity Potato = objects.closest("Potato");
        Entity Gate = objects.closest("Gate");


        if (!getInventory().isFull()) { //If my inventory is empty
            if (!Field.contains(myPlayer())) { //If Player isn't in the Field Walk to Gate
                log("Started WebWalking");
                getWalking().webWalk(Pregate);
                Gate.interact("Open");
                log("Opening Gate");
                getWalking().webWalk(Field);

            } else { // If player is in the field Start Picking
                if (Potato != null) ;
                Potato.interact("Pick");
                new ConditionalSleep(750, 500) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return myPlayer().isAnimating() && myPlayer().isMoving();
                    }
                }.sleep();

                return 600;
            }

        } else if (!Banks.DRAYNOR.contains(myPlayer())){ //If you aren't inside the bank
            getWalking().webWalk(DRAYNOR);
            log("Web walking to Bank");
            if (!getBank().isOpen()){
                getBank().open();
                new ConditionalSleep(2000,500){
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getBank().isOpen();
                    }


                }.sleep();
                getBank().depositAll();
                new ConditionalSleep(1000,500) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getInventory().isEmpty();
                    }
                }.sleep();

                getBank().close();
                new ConditionalSleep(1500,500) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return !getBank().isOpen();
                    }
                }.sleep();
            }
        }
        return 0;
    }
 }


Was actually looking through a heap of your code and it's improved so much!
Your picker inspired me to make my own lmao

Currently working on a progressive fishing script as i tried my hand at a progressive miner but couldn't for the life of me work out how to differentiate the rocks as i didn't want to use Rock IDs

As for the code tag thing, i'll make sure to do that when i update my picker as it's still got HELLA bugs in it that's screwing with my gold farming LOL

Link to comment
Share on other sites

On 11/3/2018 at 7:19 PM, Neku said:

Yeah it is, any tips?

Also there is a slight bug with banking that I need to sort out ?

The problem with your banking is that you call walking to the bank every loop. You need to check if you're in the bank to not walk. 

You need to do it like this. This will fix your banking issue and will only call walking if you're not in the bank. This portion of the code would go in the else for the !getInventory.isFull

If (!DRAYNORBANK.contains(myPlayer)) {

walking.webWalk(DRAYNOR_BANK);

} else {

if (!getBank.isOpen) {

getBank.open();

} else {

getBank.depositalAll();

}


Also you don't need to open gates with webwalker. It will do it on it's own.

Also the sleep condition can be to check if the potato you were interacting exists anymore.

Good luck

 

 

Edited by Juggles
Link to comment
Share on other sites

1 hour ago, Juggles said:

The problem with your banking is that you call walking to the bank every loop. You need to check if you're in the bank to not walk. 

You need to do it like this. This will fix your banking issue and will only call walking if you're not in the bank. This portion of the code would go in the else for the !getInventory.isFull


If (!DRAYNORBANK.contains(myPlayer)) {

walking.webWalk(DRAYNOR_BANK);

} else {

if (!getBank.isOpen) {

getBank.open();

} else {

getBank.depositalAll();

}


Also you don't need to open gates with webwalker. It will do it on it's own.

Also the sleep condition can be to check if the potato you were interacting exists anymore.

Good luck

 

 

Can't believe the legendary Juggles would comment on a shocking post like this!

As for webwalking it has a few issues trying to open the gate and then eventually breaks outside the fence hence why i had to create a gate opening event all on it's own

as for the webwalking part in the onloop() it seems i already implemented that without even realizing 

 

            }else {
                if (!flyFishing.contains(myPlayer())){
                    log("Walking to Fly Fishing Spot");
                    getWalking().webWalk(flyFishing);
                }else {
                    if (getInventory().isFull()) {
                        getInventory().dropAllExcept("Fly fishing rod", "Feather");
                    }else {
                        log("Lets start Fly Fishing");
                        if (lure != null);
                        lure.interact("Lure");
                        sleep(4000);
                        new ConditionalSleep(200000) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return !myPlayer().isAnimating();
                            }
                        }.sleep();

 

Edited by Neku
Link to comment
Share on other sites

6 hours ago, Neku said:

Can't believe the legendary Juggles would comment on a shocking post like this!

As for webwalking it has a few issues trying to open the gate and then eventually breaks outside the fence hence why i had to create a gate opening event all on it's own

as for the webwalking part in the onloop() it seems i already implemented that without even realizing 

 


            }else {
                if (!flyFishing.contains(myPlayer())){
                    log("Walking to Fly Fishing Spot");
                    getWalking().webWalk(flyFishing);
                }else {
                    if (getInventory().isFull()) {
                        getInventory().dropAllExcept("Fly fishing rod", "Feather");
                    }else {
                        log("Lets start Fly Fishing");
                        if (lure != null);
                        lure.interact("Lure");
                        sleep(4000);
                        new ConditionalSleep(200000) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return !myPlayer().isAnimating();
                            }
                        }.sleep();

 

In your new code, don't do this

       sleep(4000);
                        new ConditionalSleep(200000) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return !myPlayer().isAnimating();
                            }
                        }.sleep();

 

Instead check if you're not animating and then fish, else if you're animating do nothing

if (!myPlay.isAnimating() {

     fishingSpot.interact("Lure");

  					 new ConditionalSleep(4000) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return myPlayer().isAnimating();
                            }
                        }.sleep();

} else {
     // do nothing, we are fishing. ANTIBAN!
}

 

Edited by Juggles
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...