import org.osbot.rs07.api.model.NPC;
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.*;
@ScriptManifest(author = "You", info = "My first script", name = "Tea thiever", version = 0, logo = "")
public class main extends Script {
@Override
public void onStart() {
log("Let's get started!");
}
private enum State {
FISH, COOK, DROP
}
private State getState() {
if(inventory.isEmptyExcept(310, 17794, 309, 17795, 123, 17796) && !myPlayer().isAnimating())
return State.FISH;
if(inventory.isFull())
return State.COOK;
return State.DROP;
}
@Override
public int onLoop() throws InterruptedException {
switch(getState()) {
case FISH:
//Entity fishingSpot = objects.closest("Fishing Spot"); Wrong. Fishing spots are tied to NPCs
//You meant to do:
NPC fishingSpot = getNpcs().closest("Fishing Spot");
if (fishingSpot != null) { //ALWAYS NULL CHECK BEFORE INTERACTING..Keep this in mind. logic: if it exists -> interact
fishingSpot.interact("Lure");
//sleep
}
break;
case COOK:
//Entity fire = objects.closest("fire"); This is okay to do since Object,NPC,etc extend Entity
//but should do it like this.
RS2Object fire = getObjects().closest("Fire");
RS2Widget cookMenu = widgets.get(307, 4);
//I am going to throw some code in here for you. It will be your job to find it in the API docs and understand the methods I am implementing.
if (cookMenu != null && cookMenu.isVisible()) {
cookMenu.interact("Cook All");
//sleep
} else {
if (getInventory().isItemSelected()) {
if (fire != null) {
fire.interact("Use");
//sleep...look into ConditionalSleep
}
} else {
//item is not selected..select something
inventory.interact("Use", "Trout");
//sleep
}
}
break;
case DROP:
inventory.dropAll(331, 332, 333, 334, 25976);
break;
}
return 600; //just return a server tick 600ms
}
@Override
public void onExit() {
log("Thanks for running my first script!");
}
@Override
public void onPaint(Graphics2D g) {
}
}
Try this