Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question Close Bank Immediately After Withdraw

Joined
Nov 4, 2018
Messages
9
Is there a way to reduce/eliminate the delay between withdrawing an item and then closing the bank? i would say its in the range of 300-600ms, i have tried reducing my loop delay but no luck. I am using the following code:

if(!Inventory.contains(bot.toHumidify)) {
Bank.withdraw(bot.toHumidify, 27);
}
if(Inventory.contains(bot.toHumidify)){
Bank.close(true);
}

Any feedback welcome, thanks.
 
Community Manager
Joined
Apr 7, 2015
Messages
1,394
You should probably turn this into an if else statement, other than that I can’t really say much from only seeing these few lines
 
The Omen
Joined
Dec 27, 2018
Messages
159
Code:
if(!Inventory.contains(bot.toHumidify) && Bank.withdraw(bot.toHumidify, 27) && Bank.close()) {
     Execution.delayUntil(() -> !Bank.isOpen(), 600, 1200);
}

This statement helps you string together interactions. If the withdrawal was successful and closing the bank was successful then we will delay until the Bank is no longer open. This reduces overhead by executing multiple consecutive actions instead of looping through your task/tree structure to return to this task again.

The RuneMate api is very helpful with regards to things like this due to the return type of most methods being a boolean, letting you know if that action was successful.

Also, Bank#close will return True if the either A) the bank is not open or B) the action to close the bank was successful. This is the same with Bank#open.

Further help can be found in the jdocs, inside the Bank section.
 
cuppa.drink(java);
Joined
Mar 13, 2018
Messages
6,661
Code:
if(!Inventory.contains(bot.toHumidify) && Bank.withdraw(bot.toHumidify, 27) && Bank.close()) {
     Execution.delayUntil(() -> !Bank.isOpen(), 600, 1200);
}

This statement helps you string together interactions. If the withdrawal was successful and closing the bank was successful then we will delay until the Bank is no longer open. This reduces overhead by executing multiple consecutive actions instead of looping through your task/tree structure to return to this task again.

The RuneMate api is very helpful with regards to things like this due to the return type of most methods being a boolean, letting you know if that action was successful.

Also, Bank#close will return True if the either A) the bank is not open or B) the action to close the bank was successful. This is the same with Bank#open.

Further help can be found in the jdocs, inside the Bank section.
Interesting, I always followed the rule of thumb of always returning after an action, but I see the merit in what you're doing here. Seems potentially quicker and more responsive.
 
Community Manager
Joined
Apr 7, 2015
Messages
1,394
Interesting, I always followed the rule of thumb of always returning after an action, but I see the merit in what you're doing here. Seems potentially quicker and more responsive.
Doing it this way is more than one action per loop, which is not really a good way of writing (even if it should work)
 
cuppa.drink(java);
Joined
Mar 13, 2018
Messages
6,661
Doing it this way is more than one action per loop, which is not really a good way of writing (even if it should work)
Yeah, I know it's a bad idea in general, but I wonder if there is a way to make it work. Hypothetically it'd be more responsive if you managed to make it not-buggy. Or maybe less responsive since it might try to do more impossible actions. Hard to say.
 
Joined
Nov 4, 2018
Messages
9
The code supplied by makuto did not work in my script it froze when withdrawing from the bank.

Gengsta i am just calling
public boolean validate() {
return (Inventory.contains(bot.toHumidify));
}
each time the script loops and from that it humidifies or does my bank task, full code below for banking:


public class BankLeaf extends LeafTask {

private Gorgz_Lunar bot;

public BankLeaf(Gorgz_Lunar bot){
this.bot = bot;
}

@Override
public void execute() {
if (Bank.isOpen()) {
if (Inventory.contains(bot.enchanted)) {
Bank.depositAllExcept("Astral rune");
//Execution.delayUntil(() -> !Inventory.contains(bot.enchanted), 125, 200);
}
if(!Inventory.contains(bot.toHumidify)) {
Bank.withdraw(bot.toHumidify, 27);
//Execution.delayUntil(() -> Inventory.contains(bot.toHumidify), 125, 200);
System.out.println("Withdraw");
}
if(Inventory.contains(bot.toHumidify)){
Bank.close(true);
}
}
else {
Bank.open();
Execution.delayUntil(() -> Bank.isOpen(), 125, 200);
}
}
}
 
Top