Jump to content

[BZG] Wheat Picker v1.0


Recommended Posts

Posted (edited)

Edit: This may be better suited for Resource Collection, feel free to move if so.

Like so many others have said before, be gentle. I've written a few other very simple scripts, this is just one that I feel is decent.

It's nothing special, just a simple wheat picker with a static area to pick wheat in the field in Draynor and deposits in Draynor's bank. I used Explv's Lambda expressions for conditional sleeps.

I'm sure there's plenty of redundancies or ways to simplify/clean up the code, so if you see a way I'd love to hear it. Thanks.

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.map.Area;

@ScriptManifest(name = "[BZG] Wheat Picker v1.0", author = "bumzag", version = 1.0, info = "Picks wheat in Lumbridge and banks in Draynor.", logo = "")

public final class WheatPicker extends Script {

    private Area[] BANK = {Banks.DRAYNOR};
    private Area wheatArea = new Area(3116, 3286, 3126,  3277);

    public void onStart() throws InterruptedException {

    }
    @Override

    public void onExit() {

    }
    @Override

    public int onLoop() throws InterruptedException {

        if (checkInvIsFull())
            dumpInventory();

        else {
            if(!wheatArea.contains(myPosition()))
                getWalking().webWalk(wheatArea);

            else {
                RS2Object wheat = objects.closest("Wheat");
                long wheatBefore = getInventory().getAmount("Wheat");
                if (wheat != null) {
                    if (!myPlayer().isAnimating()) {
                        if (!myPlayer().isMoving()) {
                            if(wheat.interact("Pick"))
                            	Sleep.sleepUntil(() -> getInventory().getAmount("Wheat") > wheatBefore, 5000);
                        }
                    }
                }
            }
        }

        return(500);

    }

    private boolean checkInvIsFull() {
        return getInventory().isFull();
    }

    private void dumpInventory() throws InterruptedException {
        if(!Banks.DRAYNOR.contains(myPlayer().getPosition())) {
            getWalking().webWalk(BANK);
            Sleep.sleepUntil(() -> Banks.DRAYNOR.contains(myPosition()), 2000);
        }

        getBank().open();
        Sleep.sleepUntil(() -> getBank().isOpen(), 2000);
        getBank().depositAll();
        Sleep.sleepUntil(() -> getInventory().isEmpty(), 2000);
    }

}

Download here

Edited by bumzag
  • Like 1
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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