Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.mythicscape.batclient.interfaces.*;
- SCRIPT_NAME = "hb_bar";
- //
- // This is a small script that takes the dunk_dunks and displays them in a small bar (extra window)
- // If you encounter any problems or got idea on how to improve this script, please drop me(Tugmeno) a tell
- //
- public static BatWindow win;
- //Change the Colours here, if you don't like them R/G/B
- public static final Color cb = new Color(0,0,255); //border
- public static final Color c1 = new Color(0,255,0); //more than 2 sec untill dunk
- public static final Color c2 = new Color(255,0,0); //more than 1 sec untill dunk
- public static final Color c3 = new Color(100,100,0); // less than 1 sec untill dunk
- //If you close the window by accident just type "$hb_bar" to make it visible again
- void run(){
- win.setVisible(true);
- }
- void bootup()
- {
- win = clientGUI.createBatWindow("x",800,10,110,50); //if the window should appear at a different location change the 800 & 10
- win.removeTabAt(0);
- bp = new DunkPanel();
- win.newTab("x", bp);
- new Thread(bp).start();
- win.setVisible(true);
- triggerManager.newTrigger(SCRIPT_NAME + "dunk_dunk",
- "^Dunk dunk$",
- "$" + SCRIPT_NAME + ".dunk",
- true, // replace true with false if you want to see the dunk dunks anyway
- false, false,
- null, Font.PLAIN);
- }
- void dunk()
- {
- bp.dunk();
- }
- public class DunkPanel extends BatPanel implements Runnable {
- int x = 0;// If anyone could explain me why changing this to private makes paint bug around drop me a tell
- public dunk()
- {
- x = 3000;
- }
- public void run()
- {
- while(true)
- {
- Thread.sleep(70); // the lower the value here
- x -= 70; // the faster it updates the bar
- x = (x<0)?0:x;
- repaint();
- }
- }
- public DunkPanel()
- {
- super();
- }
- public void paint(Graphics g) {
- super.paint(g);
- g.setColor(cb);
- g.drawRect(0,0,100,20);
- int d = new Double(x/3000.0 * 100.0).intValue();
- if(d >= 66)
- g.setColor(c1);
- else if(d >= 33)
- g.setColor(c2);
- else
- g.setColor(c3);
- g.fillRect(0,0,d,20);
- }
- }
- public static DunkPanel bp;
Advertisement
Add Comment
Please, Sign In to add comment