Guest User

Untitled

a guest
Apr 23rd, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. public class SimplePowerChopper extends Script {
  2.  
  3. public final String TREE = "Tree";
  4.  
  5. private enum State {
  6. CHOP, DROP
  7. }
  8.  
  9. private State getState() {
  10. if (inventory.isFull())
  11. return State.DROP;
  12. return State.CHOP;
  13. }
  14.  
  15. @Override
  16. public void onStart() {
  17. log("Starting Script");
  18. }
  19.  
  20. @Override
  21. public int onLoop() throws InterruptedException {
  22.  
  23. switch (getState()) {
  24. case CHOP:
  25. if (!myPlayer().isAnimating()) {
  26. RS2Object tree = objects.closest("Tree");
  27. if (tree != null) {
  28. if (tree.interact("Chop"))
  29. sleep(random(1000, 1500));
  30. }
  31. }
  32. break;
  33.  
  34. case DROP:
  35. if (inventory.isFull()) {
  36. inventory.dropAll();
  37. }
  38. break;
  39. }
  40.  
  41. return random(200, 300);
  42. }
  43.  
  44. @Override
  45. public void onExit() {
  46. log("Stopping Script");
  47. }
  48.  
  49. @Override
  50. public void onPaint(Graphics2D g) {
  51. // This is the paint of the script
  52. }
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment