Hello. I am creating a woodcutting bot but i need some help with code can anyone help me out... I have inserted my code below i need help with 2 things and they are... The bot keeps spam clicking on the same tree until it chops down the tree. And i need to make the camera adjust to the tree
package Woodcutter;
import java.awt.Graphics2D;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.ui.Skill;
@ScriptManifest(author = "Test", info = "Chops", logo = "N/A", name = "WoodCutter", version = 1.0)
public class Woodcutter extends Script {
private int beginningXP;
private int currentXp;
private int xpGained;
private int currentLevel;
private int beginningLevel;
private int levelsGained;
// code to be executed at the start of script
@Override
public void onStart() {
log("Starting Woodcutter");
log("Starting Woodcutter");
beginningXP = skills.getExperience(Skill.WOODCUTTING);
beginningLevel = skills.getStatic(Skill.WOODCUTTING);
}
private enum State {
CHOP, BANK, WAIT;
};
private State getState() {
if (!(inventory.isFull()))
return State.CHOP;
if (inventory.isFull())
return State.BANK;
return State.WAIT;
}
@Override
public int onLoop() throws InterruptedException {
switch (getState()) {
case CHOP:
Entity willowTree = objects.closest("Tree");
if (willowTree != null)
willowTree.interact("Chop down");
break;
case BANK:
if (inventory.isFull()) {
inventory.dropAll();
}
break;
case WAIT:
sleep(random(500, 700));
break;
}
return 50;
}
// code to be executed at the end
@Override
public void onExit() {
}
@Override
public void onPaint(Graphics2D g) {
currentXp = skills.getExperience(Skill.WOODCUTTING);
xpGained = currentXp - beginningXP;
g.drawString("XP Gained: " + xpGained, 25, 50);
currentLevel = skills.getStatic(Skill.WOODCUTTING);
g.drawString("Beginning Level: " + beginningLevel, 25, 60);
g.drawString("Current Level: " + currentLevel, 25, 70);
levelsGained = currentLevel - beginningLevel;
g.drawString("Levels Gained: " + levelsGained, 25, 80);
}
}