Hey, I'm just getting into scripting having some java and other various programming background.
From following the tutorials I've come up with a bit of a base for a simple cow fighter which I want to build off of, and I have what I think will give me a script which will attack cows, but whenever I run it nothing happens.
Here's my onLoop() code. my onStart() code sets the current state to initialState. Any idea what I'm doing wrong?
Also I might just be blind, but if anybody could link me to a good debugging tutorial I'd be very appreciative!
public int onLoop() throws InterruptedException {
objects.closest("Cow").interact("Attack");
switch (getCurrentState()){ //state transitions
case initialState:
setState(states.lookingForFight);
break;
case inCombat:
if(!myPlayer().isUnderAttack()){
setState(states.lookingForFight);
}
break;
case lookingForFight:
if(myPlayer().isUnderAttack()){
setState(states.inCombat);
}
break;
case lowHealth:
setState(states.eating);
break;
case eating:
if (!needToEat()){
if (myPlayer().isUnderAttack()){
setState(states.inCombat);
} else{
setState(states.lookingForFight);
}
}
break;
case waiting:
break;
case finish:
break;
case bank:
break;
default:
break;
}
switch (getCurrentState()){ //state actions
case initialState:
break;
case inCombat:
break;
case lookingForFight:
log("attempting to attack");
Entity cow = objects.closest("Cow");
if(cow != null ){
cow.interact("Attack");
}
break;
case lowHealth:
break;
case eating:
getInventory().interact("Trout", "Eat");
break;
case waiting:
break;
case finish:
break;
default:
break;
}
return random(400, 1200);
}