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.

Adding a check to see if bank is open makes my script lag?

Featured Replies

Haven't scripted (or programmed) in years and started again today. I just found that adding a check to see if my bank is open makes my script lag and unusable.

 

I remember this was usually caused by executing some CPU intensive instruction in a loop but surely it's normal that this type of check is placed in a loop?

 

This is the relevant code (don't mind the conditional sleep, it's not finished): 

RS2Object bank = getObjects().closest("Bank chest");
		
if (inventory.isFull() && !b.isOpen()) {
	if (bank != null && bank.isVisible()) {
		bank.interact("Use");
		new ConditionalSleep(random(800, 1500)) {
					
			@[member=Override]
			public boolean condition() throws InterruptedException {
				return false;
			}
		};
				
	}
}

b is simply an instance of the Bank class.

 

Thanks in advance.

you should return !bank.isOpen() in your condition, that way it will only sleep when bank is not open

Edited by Woody

  • Author

you should return !bank.isOpen() in your condition, that way it will only sleep when bank is not open

 

Right, I wasn't even paying attention to the condition so that makes sense. However I tried it and the lagging still happens.

show us the code that should be executed when the bank is open

you need to call new ConditionalSleep(.....).sleep(); otherwise it won't sleep.

 

what is b?

 

would be easier to see all the code.

 

precise.

Edited by Precise

  • Author

use the instance of bank from Script

 

This worked. The confusion happened because I called my own variable for the bank chest "bank".

 

Thanks.

you need to call new ConditionalSleep(.....).sleep(); otherwise it won't sleep.

 

what is b?

 

would be easier to see all the code.

 

precise.

 

What do you mean by call new ConditionalSleep? Am I not calling it by making a new instance of it? 

This worked. The confusion happened because I called my own variable for the bank chest "bank".

 

Thanks.

 

What do you mean by call new ConditionalSleep? Am I not calling it by making a new instance of it? 

 

yes you made a new instance of it, but that is all. you need to call the sleep method otherwise it won't sleep. that is what i have experienced.

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.