Haven't scripted (or programmed) in years and started again today. I just found that adding a check to see if my bank is open makes my script lag and unusable.
I remember this was usually caused by executing some CPU intensive instruction in a loop but surely it's normal that this type of check is placed in a loop?
This is the relevant code (don't mind the conditional sleep, it's not finished):
RS2Object bank = getObjects().closest("Bank chest");
if (inventory.isFull() && !b.isOpen()) {
if (bank != null && bank.isVisible()) {
bank.interact("Use");
new ConditionalSleep(random(800, 1500)) {
@[member=Override]
public boolean condition() throws InterruptedException {
return false;
}
};
}
}
b is simply an instance of the Bank class.
Thanks in advance.