sp3cpk Posted December 12, 2016 Posted December 12, 2016 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 ?
Butters Posted December 12, 2016 Posted December 12, 2016 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
sp3cpk Posted December 12, 2016 Author Posted December 12, 2016 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?
Butters Posted December 12, 2016 Posted December 12, 2016 (edited) 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 December 12, 2016 by nosepicker
sp3cpk Posted December 12, 2016 Author Posted December 12, 2016 (edited) 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 new ConditionalSleep(2000, 100) { @@Override public boolean condition() throws InterruptedException { return getInventory.contains("item", 14) || getDialogue().inDialogue(); } }.sleep(); fixed Edited December 12, 2016 by sp3cpk
Butters Posted December 12, 2016 Posted December 12, 2016 THanks, you really got me thinking! I think i figured it out 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