Jump to content

[BZG] Wheat Picker v1.0


bumzag

Recommended Posts

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
Link to comment
Share on other sites

  • 1 year later...

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...