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.

[Help] Conditional Sleep

Featured Replies

Hey guys, my conditional sleeps usually work however for ground items I seem to be having a little bit of problems;

this is my code for that part 

 

	GroundItem item = getGroundItems().closest("item");
		if (item == null) {
			log("item is null");
			if (!magic.isSpellSelected()) {
				log("Spell is not active, activating spell");
				magic.castSpell(Spells.NormalSpells.TELEKINETIC_GRAB);
			} else {
				log("item is null, spell is active moving mouse to predicted spot");
				hoverTile.hover(bot);
				sleep(random(500, 1500));
				new ConditionalSleep(5000) {

					@Override
					public boolean condition() throws InterruptedException {
						return item.exists();
					}
				}.sleep();

			}
		}

no matter what I do it always seems to return true even if its not there 

I have tried:

item != null; (this one waits until it times out then continues)

item.isVisiable();

item.isOnScreen();

pretty much everything I can think of and nothing works right


 

Zammy wine grabber

 

Anyway, you sure its returning true and its not just waiting the 5 seconds defined by the line 

new ConditionalSleep(5000) {

// This means a max sleep of 5 seconds which is shorter than the item respawn time.
// Try new ConditionalSleep(90000) { for 1.5 minutes sleep

Also I would use item != null (Although there are other of doing it, suggest you test each one you can come up with for the fastest time).

 

Also instead of a conditional sleep, you could just change it to this which is probably better practice

else {
	if(!pos.getPolygon(bot).contains(getMouse().getPosition())){ //mouse is not hovering on tile
		//blah blah blah hover mouse
	}
}

 

 

Edited by k9thebeast

  • Author
9 minutes ago, k9thebeast said:

Zammy wine grabber

 

Anyway, you sure its returning true and its not just waiting the 5 seconds defined by the line 


new ConditionalSleep(5000) {

// This means a max sleep of 5 seconds which is shorter than the item respawn time.
// Try new ConditionalSleep(90000) { for 1.5 minutes sleep

Also I would use item != null (Although there are other of doing it, suggest you test each one you can come up with for the fastest time).

 

Also instead of a conditional sleep, you could just change it to this which is probably better practice


else {
	if(!pos.getPolygon(bot).contains(getMouse().getPosition())){ //mouse is not hovering on tile
		//blah blah blah hover mouse
	}
}

 

 

i did have it set for after re spawn rate i was just using it so that it would work; but it always fucks up;

ill give it a shot and report back

 

 

From what I understand you're simply trying to make the script wait until the wine is back on the table?  

This isn't perfect, but you could definitely build on it

In your onLoop you shouldn't make the script DyanmicSleep while waiting, just don't make it do anything.

onLoop(){

GroundItem item = groundItems.closest("item");

if(item != null || item.exists()){

   //grab that shit
}

if(item == null || !item.exists()){


 if(!magic.isSpellSelected()){
	//check if can cast, then cast spell
}
if(magic.isSpellSelected()){
	if(!magic.getSelectedSpellName().equalsIgnoreCase(NormalSpells.TELEKINETIC_GRAB.name())){
		//deselect spell only
	}

  if(!hoverTile.getPolygon(bot).contains(mouse.getPosition()){
    // hover the tile
//return 600 or whatever here. Just make the script return inside onLoop() when waiting
  }
}

}


}

 

  • Author
21 minutes ago, Polymorphism said:

From what I understand you're simply trying to make the script wait until the wine is back on the table?  

This isn't perfect, but you could definitely build on it


In your onLoop you shouldn't make the script DyanmicSleep while waiting, just don't make it do anything.

onLoop(){

GroundItem item = groundItems.closest("item");

if(item != null || item.exists()){

   //grab that shit
}

if(item == null || !item.exists()){


 if(!magic.isSpellSelected()){
	//check if can cast, then cast spell
}
if(magic.isSpellSelected()){
	if(!magic.getSelectedSpellName().equalsIgnoreCase(NormalSpells.TELEKINETIC_GRAB.name())){
		//deselect spell only
	}

  if(!hoverTile.getPolygon(bot).contains(mouse.getPosition()){
    // hover the tile
//return 600 or whatever here. Just make the script return inside onLoop() when waiting
  }
}

}


}

 

thanks mate; k9's worked perfect (:

 

12 hours ago, whipz said:

thanks mate; k9's worked perfect (:

 

 

 

No problem, hadn't noticed he already put down pretty much what i did lol. Mustve been writing it up nearly the same time.

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.