Skip to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Trying to Understand Show/Hide Paint

Featured Replies

Hello,

I was wondering if someone could explain a little more in-depth as to how showing/hiding paint works, as far as getting intractable buttons working. I've been trying to follow this tutorial/snippit (bottom of page):

 

http://osbot.org/forum/topic/59574-interactable-paint-not-working-on-osbot-2/

 

I'm just not sure where to create the buttons, where to place them, etc. Is there an easier way to implement showing and hiding paint with intractable buttons? (as if it's already kinda easy as it is unsure.png )

You need a rectangle, a boolean and a  mouse listener.

 

Rectangle:

 

MouseListener: 

 

  1. Create a rectangle
  2. Create a boolean
  3. Add a new MouseListener to the client
  4. When the mouse is clicked, grab the MouseEvent's point and check if the rectangle contains it, if so -> invert the boolean

 

 

Our mouse class

public class Mouse implements MouseListener {
    //create a boolean
    public boolean hidePaint;

    @Override
    public void mouseClicked(MouseEvent e) {
        //create our point variable
        Point p = e.getPoint();
        //create our rectangle
        Rectangle rec = new Rectangle(x,y,width,height);
        //check if the rectangle contains point and change booleans state
        if(rec.contains(p))
            hidePaint = !hidePaint;
    }

    @Override
    public void mouseEntered(MouseEvent e) {         
    }

    @Override
    public void mouseExited(MouseEvent e) {
    }

    @Override
    public void mousePressed(MouseEvent e) {
    }
    @Override
    public void mouseReleased(MouseEvent e) {
    }
}

Main class

public class Main extends Script{
    //pas our mouse object
    Mouse mouse = new Mouse();
    
    public void onStart(){
        //add our mouse object as a mouse listener
        getBot().addMouseListener(mouse);
    }

    public void onPaint(Graphics2D g){
        //check if our boolean is false
        if(!mouse.hidePaint){
            //draw our stuff
        }
    }

    public int onLoop(){
        return 0;
    }
}

Hope this helps :)

Edited by Vilius

  • Author

Thank you guys very much for explaining this to me. I really appreciate it. Everything seems to be working perfectly! biggrin.png

  • 1 year later...
On 3/16/2016 at 4:51 AM, Vilius said:

Our mouse class


public class Mouse implements MouseListener {
    //create a boolean
    public boolean hidePaint;

    @Override
    public void mouseClicked(MouseEvent e) {
        //create our point variable
        Point p = e.getPoint();
        //create our rectangle
        Rectangle rec = new Rectangle(x,y,width,height);
        //check if the rectangle contains point and change booleans state
        if(rec.contains(p))
            hidePaint = !hidePaint;
    }

    @Override
    public void mouseEntered(MouseEvent e) {         
    }

    @Override
    public void mouseExited(MouseEvent e) {
    }

    @Override
    public void mousePressed(MouseEvent e) {
    }
    @Override
    public void mouseReleased(MouseEvent e) {
    }
}

Main class


public class Main extends Script{
    //pas our mouse object
    Mouse mouse = new Mouse();
    
    public void onStart(){
        //add our mouse object as a mouse listener
        getBot().addMouseListener(mouse);
    }

    public void onPaint(Graphics2D g){
        //check if our boolean is false
        if(!mouse.hidePaint){
            //draw our stuff
        }
    }

    public int onLoop(){
        return 0;
    }
}

Hope this helps :)

Thank you, this is exactly what I was looking for.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.