Hi all, I had this code working a few years ago, but I can't seem to get it working for the life of me. Been out of coding for a while so it's probably a noob error. Buys & hops fine. But when inventory is full it doesn't bank. Any ideas? Thanks!
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import java.awt.*;
import javax.swing.text.html.parser.Entity;
@ScriptManifest(info = "GRAPE BUYER", version = 1.0, logo = "", author = "MATT", name = "GRAPE BUYER")
public class main extends Script {
enum State {
OPENCHEST, BUYGRAPES, BANK, HOP;
}
public State state;
public void onStart(){
if(getInventory().isFull())
{
state = State.BANK;
log("BANK");
}
if (!getInventory().isFull())
{
state = State.BUYGRAPES;
}
if (getInventory().onlyContains("Coins"))
{
state = State.OPENCHEST;
log("OPEN CHEST");
}
if(getStore().isOpen() && getStore().getAmount("Grapes") > 0)
{
state = State.BUYGRAPES;
}
if(getStore().isOpen() && getStore().getAmount("Grapes") == 0)
{
state = State.HOP;
}
}
public int onLoop() throws InterruptedException{
switch (state){
case OPENCHEST:
return openChest();
case BUYGRAPES:
return buyGrapes();
case BANK:
return bank();
case HOP:
return hopWorlds();
}
return random(100, 220);
}
int openChest() throws InterruptedException {
objects.closest("Chest").interact("Buy-food");
sleep(900);
if (getInventory().contains("Coins") && !getInventory().isFull())
{
if (!getStore().contains("Grapes"))
{
state = State.HOP;
log("HOPPING");
}
else if (getStore().contains("Grapes") && !getInventory().isFull())
{
log("Changing state to buying");
state = State.BUYGRAPES;
}
else if (getStore().contains("Grapes") && getInventory().isFull())
{
state = State.BANK;
}
}
return 0;
}
int buyGrapes() throws InterruptedException {
log("BUYING");
if (!store.isOpen())
{
state = state.OPENCHEST;
}
log("BUYING GRAPES NOW");
if ((store.isOpen()) && !getInventory().isFull()){
log("store is open");
sleep(300);
RS2Widget grapeWidget = getWidgets().get(300, 16, 5);
if (grapeWidget != null && grapeWidget.interact("Buy 10")) {
log("buying 10");
sleep(1000);
}
if (store.isOpen()) {
store.close();
}
if (getInventory().isFull())
{
state = State.BANK;
}
else
{
log("Hopping");
state = State.HOP;
}
}
else if (getInventory().isFull())
{
getBank().depositAllExcept("Coins");
sleep(300);
}
sleep(300);
sleep(300);
return 0;
}
int bank() throws InterruptedException{
if (getBank().isOpen()) {
getBank().depositAllExcept("Coins");
}
else if (!getBank().isOpen())
{
getBank().open();
sleep(300);
getBank().depositAllExcept("Coins");
}
sleep(300);
return 0;
}
int hopWorlds() throws InterruptedException
{
getWorlds().hopToP2PWorld();
sleep(300);
return 0;
}
}