Advertisement
EncodedScripting

Dynamic Sleep Examples

Jul 5th, 2014
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. //wait for Condition
  2.  
  3.     Condition waitForAnimation = new Condition() {
  4.         @Override
  5.         public boolean active() {
  6.             General.sleep(50, 100); // reduces cpu usage
  7.             return Player.getAnimation() != -1;
  8.         }
  9.     }
  10.            
  11.     Timing.waitCondition(waitForAnimation, General.random(1500, 2000));
  12.  
  13. //for loop
  14.  
  15.     for (int i = 0; i < 20 && Player.getAnimation() == -1; i++) {
  16.         General.sleep(75, 100);
  17.     }
  18.  
  19. //while loop
  20.  
  21.     long mark = System.currentTimeMillis();
  22.     while (Player.getAnimation() == -1 && Timing.timeFromMark(mark) <= General.random(1500, 2000)) {
  23.         General.sleep(50, 100);
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement