Guest User

hb_bar.bcs

a guest
Dec 1st, 2011
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.26 KB | None | 0 0
  1. import com.mythicscape.batclient.interfaces.*;
  2. SCRIPT_NAME = "hb_bar";
  3.  
  4. //
  5. // This is a small script that takes the dunk_dunks and displays them in a small bar (extra window)
  6. // If you encounter any problems or got idea on how to improve this script, please drop me(Tugmeno) a tell
  7. //
  8.  
  9. public static BatWindow win;
  10.  
  11. //Change the Colours here, if you don't like them R/G/B
  12. public static final Color cb = new Color(0,0,255); //border
  13. public static final Color c1 = new Color(0,255,0); //more than 2 sec untill dunk
  14. public static final Color c2 = new Color(255,0,0); //more than 1 sec untill dunk
  15. public static final Color c3 = new Color(100,100,0); // less than 1 sec untill dunk
  16.  
  17. //If you close the window by accident just type "$hb_bar" to make it visible again
  18. void run(){
  19.     win.setVisible(true);  
  20. }
  21. void bootup()
  22. {
  23.     win = clientGUI.createBatWindow("x",800,10,110,50); //if the window should appear at a different location change the 800 & 10
  24.     win.removeTabAt(0);
  25.    
  26.     bp = new DunkPanel();
  27.     win.newTab("x", bp);
  28.    
  29.    new Thread(bp).start();
  30.    
  31.    win.setVisible(true);
  32.    
  33.    triggerManager.newTrigger(SCRIPT_NAME + "dunk_dunk",
  34.         "^Dunk dunk$",
  35.      "$" + SCRIPT_NAME + ".dunk",
  36.         true, // replace true with false if you want to see the dunk dunks anyway
  37.     false, false,
  38.         null, Font.PLAIN);
  39. }
  40.  
  41. void dunk()
  42. {
  43. bp.dunk();
  44. }
  45.  
  46.  
  47.  
  48. public class DunkPanel extends BatPanel implements Runnable {
  49.     int x = 0;// If anyone could explain me why changing this to private makes paint bug around drop me a tell 
  50.       public dunk()
  51.        {
  52.           x = 3000;
  53.       }
  54.    
  55.        public void run()
  56.        {
  57.           while(true)
  58.           {
  59.           Thread.sleep(70); // the lower the value here
  60.           x -= 70;          // the faster it updates the bar
  61.           x = (x<0)?0:x;
  62.          repaint();
  63.           }
  64.        }  
  65.  
  66.        public DunkPanel()
  67.        {
  68.            super();
  69.       }
  70.       public void paint(Graphics g) {
  71.         super.paint(g);
  72.             g.setColor(cb);
  73.             g.drawRect(0,0,100,20);
  74.        
  75.       int d = new Double(x/3000.0 * 100.0).intValue();
  76.       if(d >= 66)
  77.          g.setColor(c1);
  78.       else if(d >= 33)
  79.          g.setColor(c2);
  80.       else
  81.          g.setColor(c3);
  82.      
  83.         g.fillRect(0,0,d,20);
  84.      
  85.       }
  86.    }
  87.  
  88. public static DunkPanel bp;
  89.  
  90.  
Advertisement
Add Comment
Please, Sign In to add comment