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.

Stuck on ConditionalSleep

Featured Replies

Hello guys,

Im trying to get back into scripting and my first project is a pizza base maker but im trying to add conditionalSleep

but i can get it to work.

if (new ConditionalSleep(1200)
            {
              public boolean condition()
                throws InterruptedException
              {
                return Main.this.myPlayer().isAnimating();
              }
            }.sleep()) {
            }
          }

The problem is when i make a pizza base my player isnt Animating.

(this.inventory.getAmount(new String[] { "Pizza base" }) == 9)

Ive also treid to work with the amount in inventory but still cant figure it out.

some help would be great ;)
 

Edited by Lychees

16 minutes ago, Lychees said:

Hello guys,

Im trying to get back into scripting and my first project is a pizza base maker but im trying to add conditionalSleep

but i can get it to work.


if (new ConditionalSleep(1200)
            {
              public boolean condition()
                throws InterruptedException
              {
                return Main.this.myPlayer().isAnimating();
              }
            }.sleep()) {
            }
          }

The problem is when i make a pizza base my player isnt Animating.


(this.inventory.getAmount(new String[] { "Pizza base" }) == 9)

Ive also treid to work with the amount in inventory but still cant figure it out.

some help would be great ;)
 

If there's an animation but it isn't constant you can make use of timers, I believe Juggles has a snippet in the snippet section. If there's not an animation, you can make use of the inventory.

21 minutes ago, HunterRS said:

the conditional sleep should not be inside the if, it should accure if the if statement is true.

Example:


if(getBank().depositAll()){
						new ConditionalSleep(2000) {
							@Override
							public boolean condition() {
								return getInventory().isEmpty();
							}
						}.sleep();
					}

 

Why shouldn't the conditional sleep be inside the if? ConditionalSleep#sleep returns a boolean (relating to the success), and as such can be used for conditional/ternary expressions.

@Lychees You need to find some other way to check this! Perhaps implement some kind of inventory listener of your own design, or have a concurrent timer counting the time since a pizza base was last made?

-Apa

23 minutes ago, Apaec said:

Why shouldn't the conditional sleep be inside the if? ConditionalSleep#sleep returns a boolean (relating to the success), and as such can be used for conditional/ternary expressions.

@Lychees You need to find some other way to check this! Perhaps implement some kind of inventory listener of your own design, or have a concurrent timer counting the time since a pizza base was last made?

-Apa

*facepalm*, You are right, I should go to sleep Lol

                        new ConditionalSleep(25000, 4000) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return !getInventory().contains("Pot of flour", "Jug of water")
                                        || getDialogues().inDialogue();

                            }
                        }.sleep();

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.