BrownBird Posted August 29, 2014 Share Posted August 29, 2014 Hey, was just wondering why you can't interact with paints.. Like you can't hide them ect.. Why? Link to comment Share on other sites More sharing options...
Eliot Posted August 29, 2014 Share Posted August 29, 2014 What do you mean? Unless the scripter makes it intractable it obviously won't be. Link to comment Share on other sites More sharing options...
BrownBird Posted August 29, 2014 Author Share Posted August 29, 2014 (edited) I've made all my scripts with intractable paints.. The code I am currently using doesn't work? boolean hide; Point p; Rectangle hideBox = new Rectangle(52, 41, 70, 81); public void mouseEntered(MouseEvent e) { p = e.getPoint(); if(hideBox.contains(p) && !hide) { hide= true; } else if(hideBox.contains(p) && hide){ hide = false; } } and then in the paint section.. if (!hide) { g.drawString("Showing Paint...", 0,0) } else { g.drawString("Not Showing PAint...",0,0) Thanks for the help! Edited August 29, 2014 by BrownBird Link to comment Share on other sites More sharing options...
Eliot Posted August 29, 2014 Share Posted August 29, 2014 I've made all my scripts with intractable paints.. The code I am currently using doesn't work? boolean hide; Point p; Rectangle hideBox = new Rectangle(52, 41, 70, 81); public void mouseEntered(MouseEvent e) { p = e.getPoint(); if(hideBox.contains(p) && !hide) { hide= true; } else if(hideBox.contains(p) && hide){ hide = false; } } and then in the paint section.. if (!hide) { g.drawString("Showing Paint...", 0,0) } else { g.drawString("Not Showing PAint...",0,0) Thanks for the help! public class BotMouseListener implements MouseListener { @Override public void mouseClicked(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent e) { // PUT YOUR MOUSE CODE HERE!!!!!!!! } @Override public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub } } // IN onStart METHOD! MouseListener bml = new BotMouseListener(); bot.addMouseListener(bml); Link to comment Share on other sites More sharing options...
BrownBird Posted August 29, 2014 Author Share Posted August 29, 2014 (edited) Ahh I see, I'll try it out! Thanks! ^.^ Edit.. Not working .. just gunna play with it for now Edited August 29, 2014 by BrownBird Link to comment Share on other sites More sharing options...
FrostBug Posted August 29, 2014 Share Posted August 29, 2014 The only difference is that in OSB2, the Script class doesnt implement MouseListener by default. You have to manually add your mouselistener Link to comment Share on other sites More sharing options...
Pug Posted August 29, 2014 Share Posted August 29, 2014 here, example usage of how to hide a paint: declare your hide and show images at the top of your script with your variables: private final Image showImage = getImage("http://s28.postimg.org/hcce8fx9l/show_fw.png"); private final Image hideImage = getImage("http://s29.postimg.org/8g0qpcipv/hide_fw.png"); you need a tiny method to grab images from the internet, so put this below the above: private Image getImage(String url) { try { return ImageIO.read(new URL(url)); } catch (IOException e) {} return null; } next you need to declare your point to click on so put this below the above with your other variables ^ : Point p; next you need your boolean for whether your paint is hidden or not and declare it, put this below the above: boolean hide = false; next you need two rectangles, one for where you click to hide the paint and the next for where you click to show it, declare these with your variables to: (check the api to find out which numbers are which) Rectangle close = new Rectangle(10, 457, 118, 20); Rectangle open = new Rectangle(10, 457, 118, 20); now in your onStart() method you need to put this: bot.addMouseListener(new MouseListener() {//register a new MouseListener @Override public void mouseClicked(MouseEvent e) { p = e.getPoint(); if (close.contains(p) && !hide) { hide = true; } else if (open.contains(p) && hide) { hide = false; } } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } }); next you need to sort out your onPaint method, so that you have two if statements like this: public void onPaint(Graphics2D g) { Graphics2D gr = g; if (!hide) { // put your paint in here e.g: g.drawString(ft(timeRan), 295, 349); } if (hide) { // here you put the image to show when your paint is hidden e.g: g.drawImage(this.showImage, 10, 457, null); } } if you have any more questions, pm me. a like for this post wouldnt go a miss it took a little while lol. Link to comment Share on other sites More sharing options...