Jump 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.

Calling onPaint()?

Featured Replies

Hello.

 

I am making a on screen GUI (paint) for my script and currently have all my code in the onPaint() method. The issue is my counter (in onLoop) occurs in a while loop and so the paint does not get updated until the while loop ends. Is there a way to call onPaint() in the while loop? The Client.onPaint() says it is depreciated.

 

Thanks!

Edited by NewmansScripts

You should avoid using while loops, because poorly coded ones can result in an infinite loop. You'd have to show us your code before we can get a better understanding of your problem. Where exactly did you place the while loop?

I've never run into this problem but, shouldn't paint update it whether or not it is in the onLoop?

I've never run into this problem but, shouldn't paint update it whether or not it is in the onLoop?

 

Yes, the onPaint runs independently from the onLoop. However, if some while loop is preventing the updating of a variable--which the onPaint is calling--then the variable won't change.

int count = 0;
	
	@Override
	public int onLoop() throws InterruptedException {
		
		count = 0;
		while (SOME_CONDITION_SOON_TO_END) {
			
			...
			
		}
		count++;
		
		return 100;
	}
	
	@Override
	public void onPaint(Graphics2D g) {
		
		g.drawString("Count: " + count, 25, 25);
		
	}

The counter is being updated AFTER the loop. The onPaint doesn't receive a new value until then.

Edited by liverare

  • Author

Sorry my mistake. The counter is being updated in onMessage() shown here:

public void onMessage(Message message) throws java.lang.InterruptedException {
		String txt = message.getMessage().toLowerCase();
		if (txt.contains("you hammer")) {
			barsDone++;
		}
	}

There is a while statement in my while loop that check for the animation which as print the message that I am looking for.


Fixed the issue. Did away with my while loop. Seems like that was causing the issue

Edited by NewmansScripts

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

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.