Jump to content

Sleep while performing task in inventory


sp3cpk
 Share

Recommended Posts

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 ?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...