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.

Sleep while performing task in inventory

Featured Replies

Hey so i've been experimenting with osbots API. I created a script that performs a task in your inventory. However, I have a problem and I'm hoping someone can help me out.

 

Script:

1)Takes items out of bank

2)Uses item on item

 

PROBLEM:

How would I add a sleep (using what condition)? I ask this because my player does no animation while using item on item.

 

I did try using 

 

while(!getInventory().getAmount("item") == 14){

sleep(500);

}

 

When I level up a skill my player will stay idle, so what other condition can i use ?

Conditional sleep is your friend

new ConditionalSleep(2000, 100) {
                        @[member=Override]
                        public boolean condition() throws InterruptedException {
                            return bank.withdraw("Item", 14);
                        }
                       }.sleep();

This will wait until it withdraws 14 "Items" from bank

  • Author

Conditional sleep is your friend

new ConditionalSleep(2000, 100) {
                        @[member='Override']
                        public boolean condition() throws InterruptedException {
                            return bank.withdraw("Item", 14);
                        }
                       }.sleep();

This will wait until it withdraws 14 "Items" from bank

 

Thanks:), I do understand how to use the conditional sleep method (even though i didn't use it in my example). When my player performs the task in the inventory (use 14 items on 14 items to get 14 items), it will eventually level up a skill and just stand because it's 'sleeping' ( using my condition doesn't have 14 of the specific item in inventory). So my question is what condition can i use to make it detect that the interaction has been cancelled because a skill was leveled up?

Thanks:), I do understand how to use the conditional sleep method (even though i didn't use it in my example). When my player performs the task in the inventory (use 14 items on 14 items to get 14 items), it will eventually level up a skill and just stand because it's 'sleeping' ( using my condition doesn't have 14 of the specific item in inventory). So my question is what condition can i use to make it detect that the interaction has been cancelled because a skill was leveled up?

 

I can't remember if there's a method something like inventory.interactAll("Item", "Use") and interact with a another item. You can simply always check 

if (inventory.getAmount("Item1) > 0 || inventory.getAmount("Item2) > 0) {
   // Do some interacting
}

If a level up dialog appears it will simply keep on interacting cause the above mentioned condition will still be true. Also you can add (though I don't think you need it) something like

if(dialogues.isPendingContinuation()) {
  dialogues.clickContinue();
}

Don't have an IDE running so the method names might be a bit off. This will click continue on the "You have leveled up" screen

Edited by nosepicker

  • Author

I can't remember if there's a method something like inventory.interactAll("Item", "Use") and interact with a another item. You can simply always check 

if (inventory.getAmount("Item1) > 0 || inventory.getAmount("Item2) > 0) {
   // Do some interacting
}

If a level up dialog appears it will simply keep on interacting cause the above mentioned condition will still be true. Also you can add (though I don't think you need it) something like

if(dialogues.isPendingContinuation()) {
  dialogues.clickContinue();
}

Don't have an IDE running so the method names might be a bit off. This will click continue on the "You have leveled up" screen

THanks, you really got me thinking! I think i figured it out smile.png

new ConditionalSleep(2000, 100) {

@@Override

public boolean condition() throws InterruptedException {

return getInventory.contains("item", 14) || getDialogue().inDialogue();

}

}.sleep();

 

 

fixed

Edited by sp3cpk

THanks, you really got me thinking! I think i figured it out smile.png

new ConditionalSleep(2000, 100) {

@@Override

public boolean condition() throws InterruptedException {

return !getInventory.contains("item", 14) || getDialogue().inDialogue();

}

}.sleep();

 

Well this will sleep UNTIL you are in dialogue or if you don't have 14 items in inventory. So dunno if this is what you want

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.