Alright, so here is what I've been working on:
@ScriptManifest(author = "Magerange", name = "JugFiller", info = "Fills jugs with water in east Falador", version = 1.0, logo = "")
public final class Main extends Script {
private final Area Pump = new Area (2947, 3382, 2948, 3383);
@Override
public final int onLoop() throws InterruptedException {
if (canFill()){
fill();
} else {
bank();
}
return random(175, 270);
}
private boolean canFill() {
return getInventory().contains("Jug");
}
private boolean pumpUsable(){
return Pump.contains(myPlayer());
}
Entity wPump = getObjects().closest("Waterpump");
private void fill() {
if (!Pump.contains(myPosition())){
getWalking().webWalk(Pump);
} else if (pumpUsable()) {
if (wPump != null)
inventory.interact("Use","Jug");
wPump.interact("Use");
} else {
new ConditionalSleep(1500) {
@Override
public boolean condition() {
return myPlayer().isAnimating();
}
}.sleep();
}
}
private void bank() throws InterruptedException {
if(!Banks.FALADOR_EAST.contains(myPosition())) {
getWalking().webWalk(Banks.FALADOR_EAST);
} else if (!getBank().isOpen()) {
getBank().open();
} else if (!getInventory().isEmptyExcept("Jug")) {
getBank().depositAll();
} else if (getBank().contains("Jug")) {
getBank().withdrawAll("Jug");
} else {
stop(true);
}
}
}