Deceiver Posted August 9, 2015 Posted August 9, 2015 As some of u know, I put out a little powerminer for the WWF area, it works all dandy and well besides the spam clicking for object interaction: https://vid.me/ZXMF And code: if (MINING.contains(this.myPlayer())) { final Entity rock = objects.closest("Pile of rock"); if (rock != null && rock.isVisible() && !this.myPlayer().isAnimating()) { rock.interact("Mine"); ConditionalSleep(2000); } else { camera.toEntity(rock); Could anyone provide insight on to why it spam clicks?
Bobrocket Posted August 9, 2015 Posted August 9, 2015 ConditionalSleep(2000); Does nothing. You want to either do: sleep(2000); or new ConditionalSleep(2000) { //Until condition() is met OR 2000 ms passes @Override public boolean condition() { return myPlayer().isAnimating(); } }.sleep(); 1
Mysteryy Posted August 9, 2015 Posted August 9, 2015 When you are mining, like cooking, there are breaks in animations while you are still mining. If you are only using isAnimating, then even though you are still mining, there will be a split second where isAnimating will return false, i.e. a break in the animation. Even though your player will continue mining after that split second break, the script will only know that the player is not animating, and it will try to interact again. You need to have some tracker to see how long you have been idle for. For example, only interact if you are idle for > 300 ms. Then if a animation break last 100 ms, the animation break will not trigger another interaction. If that makes sense. 1
Deceiver Posted August 9, 2015 Author Posted August 9, 2015 ConditionalSleep(2000); Does nothing. You want to either do: sleep(2000); or new ConditionalSleep(2000) { //Until condition() is met OR 2000 ms passes @Override public boolean condition() { return myPlayer().isAnimating(); } }.sleep(); I'll look into both methods, thanks!
Omicron Posted August 9, 2015 Posted August 9, 2015 (edited) When you are mining, like cooking, there are breaks in animations while you are still mining. If you are only using isAnimating, then even though you are still mining, there will be a split second where isAnimating will return false, i.e. a break in the animation. Even though your player will continue mining after that split second break, the script will only know that the player is not animating, and it will try to interact again. You need to have some tracker to see how long you have been idle for. For example, only interact if you are idle for > 300 ms. Then if a animation break last 100 ms, the animation break will not trigger another interaction. If that makes sense. I didn't know that actually, thanks for the info! (I haven't run into this problem in my cooking script, although that's probably cause I test multiple conditions, I'll look into this more) @OP Use normal sleep as mentioned above or properly implement conditional sleep Edited August 9, 2015 by Omicron