Hello,
I'm new to osrs scripting and having trouble getting a simple pray pot drinker to work. Here is a snippet:
public final int onLoop() throws InterruptedException {
// drinks potion when prayer falls under 10.
if (getSkills().getDynamic(Skill.PRAYER) < 10){
drinkPotion();
}
return 0;
}
public void drinkPotion(){
// if slot contains prayer pot, it is drank and loop is exited.
for (int i = 0; i <= 28; i++) {
if (getInventory().getItemInSlot(i).nameContains("Prayer potion(4)", "Prayer potion(3)", "Prayer potion(2)", "Prayer potion(1)")) {
getInventory().interact(i, "Drink");
break;
}
}
}
Program works perfectly without the conditional that prayer be under 10. With it, once the conditional is met, the client (not the game) freezes. Any help would be appreciated, thanks.
EDIT: was a simple counting from zero error. (should be <=27)