Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.osbot.rs07.api.map.Area;
- import org.osbot.rs07.api.model.RS2Object;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- import org.osbot.rs07.utility.ConditionalSleep;
- import java.awt.*;
- @ScriptManifest(author = "LRDBLK", info = "Chops wood", name = "Wood Chopper", version = 1, logo = "")
- public class main extends Script {
- //////////////////////
- // REQUIRED METHODS //
- //////////////////////
- @Override
- public void onStart() {
- log("Script is starting!");
- }
- @Override
- public int onLoop() throws InterruptedException {
- Area lumbridgeTrees = new Area(3176, 3238, 3200, 3207);
- /* If the inventory is full. */
- if(inventory.isFull()){
- inventory.dropAll();
- }
- /* If we're in the right area. */
- if (!lumbridgeTrees.contains(myPlayer())){
- log("walking to area now");
- getWalking().webWalk(lumbridgeTrees.getRandomPosition());
- }
- /* Default action. */
- else{
- RS2Object tree = getObjects().closest(lumbridgeTrees, "Tree");
- chopTree(tree);
- }
- return random(200, 300);
- }
- @Override
- public void onExit() {
- log("RawR");
- }
- ////////////////////
- // HELPER METHODS //
- ////////////////////
- /**
- * Checks if the player is able to perform an action.
- * @return True if player isn't performing an action.
- */
- private Boolean ableToWork(){
- return !myPlayer().isAnimating() && !myPlayer().isMoving();
- }
- /**
- * Chops a tree.
- * @params tree - The tree object to interact with.
- */
- private void chopTree(RS2Object tree){
- if(tree != null && ableToWork()){
- log("Picked new tree!");
- tree.interact("Chop down");
- }
- new ConditionalSleep(3000){
- public boolean condition(){
- return myPlayer().isAnimating();
- }
- }.sleep();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement