Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.99 KB | None | 0 0
  1. import org.osbot.rs07.api.map.Area;
  2. import org.osbot.rs07.api.model.RS2Object;
  3. import org.osbot.rs07.script.Script;
  4. import org.osbot.rs07.script.ScriptManifest;
  5. import org.osbot.rs07.utility.ConditionalSleep;
  6.  
  7. import java.awt.*;
  8.  
  9. @ScriptManifest(author = "LRDBLK", info = "Chops wood", name = "Wood Chopper", version = 1, logo = "")
  10. public class main extends Script {
  11.  
  12.  
  13.  
  14.     //////////////////////
  15.     // REQUIRED METHODS //
  16.     //////////////////////
  17.  
  18.     @Override
  19.     public void onStart() {
  20.         log("Script is starting!");
  21.     }
  22.  
  23.     @Override
  24.     public int onLoop() throws InterruptedException {
  25.         Area lumbridgeTrees = new Area(3176, 3238, 3200, 3207);
  26.         /* If the inventory is full. */
  27.         if(inventory.isFull()){
  28.             inventory.dropAll();
  29.         }
  30.         /* If we're in the right area. */
  31.         if (!lumbridgeTrees.contains(myPlayer())){
  32.             log("walking to area now");
  33.             getWalking().webWalk(lumbridgeTrees.getRandomPosition());
  34.         }
  35.         /* Default action. */
  36.         else{
  37.             RS2Object tree = getObjects().closest(lumbridgeTrees, "Tree");
  38.             chopTree(tree);
  39.         }
  40.         return random(200, 300);
  41.     }
  42.  
  43.     @Override
  44.     public void onExit() {
  45.         log("RawR");
  46.     }
  47.  
  48.  
  49.  
  50.     ////////////////////
  51.     // HELPER METHODS //
  52.     ////////////////////
  53.  
  54.     /**
  55.      * Checks if the player is able to perform an action.
  56.      * @return True if player isn't performing an action.
  57.      */
  58.     private Boolean ableToWork(){
  59.         return !myPlayer().isAnimating() && !myPlayer().isMoving();
  60.     }
  61.  
  62.     /**
  63.      * Chops a tree.
  64.      * @params tree - The tree object to interact with.
  65.      */
  66.     private void chopTree(RS2Object tree){
  67.         if(tree != null && ableToWork()){
  68.             log("Picked new tree!");
  69.             tree.interact("Chop down");
  70.         }
  71.         new ConditionalSleep(3000){
  72.             public boolean condition(){
  73.                 return myPlayer().isAnimating();
  74.             }
  75.         }.sleep();
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement