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.

Conditional Sleep Confusion

Featured Replies

editted for terrible formatting (and continued formatting)

 

So for my first few scripts I've just been using normal sleep where it waits a random amount of time before going on to the next action.

 

But I saw that it was recommended to minimize that form and prioritize conditional sleep in scripts.  From my understanding, conditional sleep continues only in the case of (A) the condition has been met or (B) the timeout has expired.  However, what happens if the interior condition is immediately proved true, but a new action can't occur because of a necessary wait time?

 

Alching, for example, would just result in a ridiculous amount of spamming when used like -

if(script.inventory.interact("CAST", "Maple Bow")){
     new ConditionalSleep(1200) {
	public boolean condition() throws InterruptedException
	      return !script.myPlayer().isAnimating();
         }
}.sleep();

Edited by Smuds

I'm sure if you put a small sleep right before the conditional it would work

Change the sleep to return when the player is animating. This way after you interact, it will sleep until you are animating.

if(script.inventory.interact("CAST", "Maple Bow") && !script.myPlayer().isAnimating()){
     new ConditionalSleep(1200) {
	public boolean condition() throws InterruptedException
	      return script.myPlayer().isAnimating();
         }
}.sleep();
  • Author

I'm sure if you put a small sleep right before the conditional it would work

A mix of the two does seem desirable, but at that point, it almost seems like you might as well just use a plain sleep because that's what is actually doing the waiting.

 

 

Change the sleep to return when the player is animating. This way after you interact, it will sleep until you are animating.

if(script.inventory.interact("CAST", "Maple Bow") && !script.myPlayer().isAnimating()){
     new ConditionalSleep(1200) {
	public boolean condition() throws InterruptedException
	      return script.myPlayer().isAnimating();
         }
}.sleep();

 

The way I understand it, the problem is not that the player is animating, it's that there's something like a cool down for the spell.  If that is the case, then this wouldn't change the problem.

A mix of the two does seem desirable, but at that point, it almost seems like you might as well just use a plain sleep because that's what is actually doing the waiting.

 

 

The way I understand it, the problem is not that the player is animating, it's that there's something like a cool down for the spell.  If that is the case, then this wouldn't change the problem.

You can set your onloop() to handle things like this and other issues. You know for sure that the onloop() is going to be looping until script stop. You can define the cooldown then the conditional sleep after like another poster said.

Alching is like a 2s delay?

do your sleep(2000,2500) and put your conditionalsleep after.

could change the sleep condition to 'item stack amount decreased && not animating anymore'

long itemCount = getInventory().getAmount("Item");
if(getMagic().castSpell(Spells.NormalSpells.SPELL_NAME)) {
new ConditionalSleep(3000) {
    public boolean condition() throws InterruptedException
     return !script.myPlayer().isAnimating() && getInventory().getAmount("Item") < itemCount; // if our new inventory count of the alch item is less than the previouscount
}
}.sleep();
 
}
 

 

did this without an ide so there may be typos etc

  • Author

Yeah I think that would definitely work, I'll put it in and report back how it works.

could change the sleep condition to 'item stack amount decreased && not animating anymore'

 

That, or alternatively:

var ALCH_WAIT_IN_MS = 1000
var lastAlchTime


IF currentSysTime LESS THAN lastAlchTime
THEN wait
ELSE IF performAlchClick
THEN SET lastAlchTime TO currentSysTime + ALCH_WAIT_IN_MS

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.