- Joined
- Feb 9, 2019
- Messages
- 44
- Thread Author
- #1
I have been writing my fletching bot to interact with logs and try to withdraw them from the bank. Knowing that there is currently a bug that despite the bank successfully withdrawing items, it can still return false. As such I decided to try and do a test with the Inventory to check when the required number of items was actually withdrawn. In the below code I simply used the Execution.delay inside to delay between withdrawing the logs and checking the inventory.
Heres the output:
---Start getting item Maple logs in quantity: 13
How did I go with: Maple logs in quantity: 13
returned out...ret false inv quantity: 13
How did I go with: Maple logs in quantity: 13
returned out...ret false inv quantity: 26
---Complete: true
The internal function does appear to work, though despite returning "true", the Exeuction.delayUntil does not quit. What have I missed in terms of how to write this function? I know I could do the check first then do the execution so I don't need an internal delay, but generally speaking, have I miunderstood an aspect of it? Or is there a bug in it?
lb25
Code:
String key = "Maple logs";
int required = 13;
System.out.println("---Start getting item " + key + " in quantity: " + required);
boolean res = Execution.delayUntil(() -> {
boolean ret = Bank.withdraw(key, required);
System.out.println("How did I go with: " + key + " in quantity: " + required);
Execution.delay(100);
if (ret || Inventory.getQuantity(key) >= required || Inventory.isFull()) {
System.out.println("returned out...ret " + Boolean.toString(ret) + " inv quantity: " + Inventory.getQuantity(key));
return true;
}
return false;
} , 3000, 5000);
System.out.println("---Complete: " + Boolean.toString(res));
Heres the output:
---Start getting item Maple logs in quantity: 13
How did I go with: Maple logs in quantity: 13
returned out...ret false inv quantity: 13
How did I go with: Maple logs in quantity: 13
returned out...ret false inv quantity: 26
---Complete: true
The internal function does appear to work, though despite returning "true", the Exeuction.delayUntil does not quit. What have I missed in terms of how to write this function? I know I could do the check first then do the execution so I don't need an internal delay, but generally speaking, have I miunderstood an aspect of it? Or is there a bug in it?
lb25