Hello osbot community, I've recently made an attempt at creating a script for osbot but i've had some problems;
Im trying to recreate a thieving script (Master farmer) But im having some issues with using food
>It detects if my hp is below 45%
>eats one piece of food
**Starts dropping all items while inventory isn't full**
I just need some advice on how to write it the good way im still in the proccess of learning so any piece of information is welcome.
**Also what i noticed that npcs.getclosest Laggs extremely badd is there a way arround that?
**And how should i improve the Npc clicking /timing?
///////////////////////////////////////
private enum State {
STEAL,
DROP,
EAT,
IDLE
};
///////////////////////////////
private State getState() {
if(myPlayer().getHealth() <45){
return State.EAT;
}
if (inventory.isFull())
return State.DROP;
return State.STEAL;
}
////////////////////////////////////
@Override
public void onStart() {
log("Let's thief!");
}
////////////////////////////////////////////////////
@Override
public int onLoop() throws InterruptedException {
switch (getState()) {
case STEAL:
if (!myPlayer().isAnimating()) {
NPC farm = npcs.closest("Master farmer");
if(farm != null){
farm.interact("pickpocket");
}
}
break;
case EAT:
if(inventory.contains("Pike")){
inventory.getItem("Pike").interact("Eat");
}
case DROP:
inventory.dropAll();
break;
case IDLE:
sleep(200);
break;
default:
break;
}
return random(200, 300);
}
////////////////////////////////////////////
@Override
public void onExit() {
log("Thanks for running my script.");
}
@Override
public void onPaint(Graphics2D g) {
}
}