I have been somewhat successful in creating a Woodcutter. One issue I am having though is that once my bot gets 26 Oak logs in it's inventory, it should bank. Rather than banking, my bot will go all the way to the bank, pause, then forget about banking, just to go back to the trees with a full inventory, and loop this error again.
/* WhizCutter Alpha Ver. 1.0
Created by Happy
Chop trees in Lumbridge and banks them.
Still waiting for first test.
Bot got stuck after banking it's first load. If the bot is stuck in Lumby bank, it is probably searching for trees.
Take back down to the trees behind the castle. Close the script, then restart it. The bot should now find trees.
Possibly create one for different types of trees? Give ability to switch tree or location?
Make sure to refresh bots(at times banking metod
*/
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;
import java.util.function.BooleanSupplier;
@ScriptManifest(name = "WhizCutter", author = "Happy", info = "Cuts trees in Lumbridge", version = 1.0, logo = "")
public final class WhizCutter extends Script {
private final Area LumbyBank = new Area(3208, 3216, 3210, 3220);
private final Area LumbyTrees = new Area(3197, 3208, 3187, 3235);
private final Area VarrockWestBank = new Area(3180,3434,3185,3444);
private final Area VarrockFrontOaks = new Area(3215,3359,3198,3373);
@Override //Loops over and over until exit
public final int onLoop() throws InterruptedException {
Woodcut(); //May not need this line of code in the near future, but will need banking spots
chopOakWood();
if (shouldIBankLogs() >= 26) {
bank();
}
return random(1000, 4000);
}
//Methods from here on alphabetized
private void bank() throws InterruptedException {
if (!Banks.VARROCK_WEST.contains(myPosition())) {
getWalking().webWalk(Banks.VARROCK_WEST);
}
else if (!getBank().isOpen()) {
getBank().open();
}
else if (!getInventory().isEmptyExcept("Oak logs")) {
getBank().depositAll("Oak logs");
}
//stop(true);
}
private boolean chopOakWood() {
return getObjects().closest("Oak").interact("Chop down");
}
private boolean chopWood() {
return getObjects().closest("Tree").interact("Chop down");
}
private boolean inventoryIsFull() {
return getInventory().isFull();
}
private long shouldIBankLogs() {
return getInventory().getAmount("Oak logs");
}
private void Woodcut() {
if (!VarrockFrontOaks.contains(myPosition())) {
getWalking().webWalk(VarrockFrontOaks);
}
}
}
import org.osbot.rs07.utility.ConditionalSleep;
import java.util.function.BooleanSupplier;
class Sleep extends ConditionalSleep {
private final BooleanSupplier condition;
public Sleep(final BooleanSupplier condition, final int timeout) {
super(timeout);
this.condition = condition;
}
@Override
public final boolean condition() throws InterruptedException {
return condition.getAsBoolean();
}
public static boolean sleepUntil(final BooleanSupplier condition, final int timeout) {
return new Sleep(condition, timeout).sleep();
}
}