Jump to content

Iron Miner (East Varrock)


Imthabawse

Recommended Posts

Mines ore's and banks them. Simple. Planning on getting into GUI to add option's like drop OR bank. Any tip's on how to go about that would be helpful! I also know there are guides on here and will be reading them as well. 

 

CODE: 

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


@ScriptManifest(name = "Iron miner", logo = "", version = 1, author = "Imthabawse", info = "Mine & Drop Iron ore")

public class Iron extends Script {

    private Area ironArea = new Area(3288, 3371, 3284, 3367);


    private void bank() {
        if (Banks.VARROCK_EAST.contains(myPlayer())) {
            RS2Object banker = getObjects().closest("Bank booth");
            log("In bank.. getting closest banker.");
            if (banker != null) {
                banker.interact("Bank");
                log("Banking..");
                new ConditionalSleep(2000) {
                    @Override
                    public boolean condition() {
                        return bank.isOpen() && getInventory().isEmpty();
                    }
                }.sleep();
            }
            if (bank.isOpen()) {
                bank.depositAll();
            }
        } else {
            if (!Banks.VARROCK_EAST.contains(myPlayer())) {
                getWalking().webWalk(Banks.VARROCK_EAST);
            log("Not in bank.. walking there.");
            }
        }
    }



    private void mineIron() {
        if (ironArea.contains(myPlayer())) {
            if (!myPlayer().isAnimating()) {
                if (!myPlayer().isMoving()) {
                    if (!getInventory().isFull()) {
                        RS2Object ironore = getObjects().closest(7488);
                        log("Getting closest iron ore.");
                        if (ironore != null) {
                            ironore.interact("Mine");
                            log("Mining..");
                            new ConditionalSleep(3500) {
                                @Override
                                public boolean condition() {
                                    return myPlayer().isAnimating() && myPlayer().isMoving();
                                }
                            }.sleep();
                        }
                    }
                }
            }
        }else{
            if(!ironArea.contains(myPlayer())) {
                log("Walking to mining area. ");
                getWalking().webWalk(ironArea);
            }
        }
    }



    @Override
    public int onLoop() {
        if(getInventory().isFull()) {
            log("Inventory FULL banking.");
            bank();
        }else{
            mineIron();
        }
        return 1500;
    }
}

 

Link to comment
Share on other sites

Nice work, no need get the bank booth as an object, use getBank().open() instead.
Also add some verifications, instead of:

if (bank.isOpen()) {
                bank.depositAll();
            }

Do something like:

if (bank.isOpen()) {
	if(bank.depositAll()) {
		//Here you should sleep untill inventory is empty
	}
}

Do stuff like this throughout your code.

Also, in the confitional sleep in the bank method you use:

return bank.isOpen() && getInventory().isEmpty();

When sleeping after just opening the bank, seperate this to just bank.isOpen() and then later verify the inventory is empty. The way it is now I am pretty sure it will always sleep on the first time you one the bank.

  • Like 1
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...