- Joined
- Feb 23, 2019
- Messages
- 34
- Thread Author
- #1
I'm trying to perform multiple actions in one LeafTask as follows:
The results vary. Sometimes it will try to walk before it's finished checking the trap, other times it will try to walk where the trap was laid during the checking animation and drop the box trap on the current position rather than on the coord of the checked box trap.
Am I missing some sort of delay between these interactions, simply doing it wrong, or maybe this should be further broken down to more branches first?
Code:
GameObject trap = GameObjects.newQuery().names("Shaking box").reachable().results().nearest();
SpriteItem invTrap = Inventory.newQuery().names("Box trap").results().random();
if(trap != null && invTrap != null){
System.out.println("trap position: " + trap.getPosition().toString());
// get location of nearest trap
Coordinate trapCoord = trap.getPosition();
// check trap by clicking
if (trap.interact("Check")) {
Execution.delayUntil(() -> Vars.player.getAnimationId() != -1, 5000);
}
// move back to checked trap position
if (trapCoord.interact("Walk here")) {
Execution.delayUntil(() -> Vars.player.getAnimationId() != -1, 5000);
}
// replace trap
if(invTrap.interact("Lay")){
Execution.delayUntil(() -> Vars.player.getAnimationId() != -1, 5000);
}
}
The results vary. Sometimes it will try to walk before it's finished checking the trap, other times it will try to walk where the trap was laid during the checking animation and drop the box trap on the current position rather than on the coord of the checked box trap.
Am I missing some sort of delay between these interactions, simply doing it wrong, or maybe this should be further broken down to more branches first?