Jusple Posted March 15, 2015 Share Posted March 15, 2015 Title says it all, Script interacts with furnace, chooses a bar and types a random number. My question is, is there a specific way to stop that loop and continue after its done? or do I have to make some kind of timer. cheers. Quote Link to comment Share on other sites More sharing options...
VladBots Posted March 15, 2015 Share Posted March 15, 2015 You need to make a system so it stops re-interacting while it is smelting. Sleeping for a long time is not a good idea. Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 15, 2015 Share Posted March 15, 2015 Just use: if(!myPlayer().isAnimating()) { smelt sleep } Quote Link to comment Share on other sites More sharing options...
Mysteryy Posted March 15, 2015 Share Posted March 15, 2015 or do I have to make some kind of timer. Quote Link to comment Share on other sites More sharing options...
Reid Posted March 15, 2015 Share Posted March 15, 2015 do { sleep(10); } while(myPlayer().isAnimating()); not the best way of doing it but it should work Quote Link to comment Share on other sites More sharing options...
Tom Posted March 16, 2015 Share Posted March 16, 2015 do { sleep(10); } while(myPlayer().isAnimating()); not the best way of doing it but it should work The animation stops between each bar that is smelted. The best way to do this is to record the currentTimeMillis when the player is animating, then check if that recorded time has been increased by x amount of milliseconds, and if thats true then allow it to continue. I can show you a snippet perhaps when I get home. Quote Link to comment Share on other sites More sharing options...
Nightchillz Posted March 16, 2015 Share Posted March 16, 2015 (edited) private State getState() { if (inventory.isFull()) return State.Bankrun or whatever you are using link to your Banking Enum... I think? im learning Edited March 16, 2015 by Nightchillz Quote Link to comment Share on other sites More sharing options...
Tom Posted March 16, 2015 Share Posted March 16, 2015 private State getState() { if (inventory.isFull()) return State.Bankrun or whatever you are using link to your Banking Enum... I think? im learning Depending on what you smelt, you are never going to have a full inventory. Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 16, 2015 Share Posted March 16, 2015 The animation stops between each bar that is smelted. The best way to do this is to record the currentTimeMillis when the player is animating, then check if that recorded time has been increased by x amount of milliseconds, and if thats true then allow it to continue. I can show you a snippet perhaps when I get home. Just add a sleep long enough till it animates again if it will take 1 second for it to animate again add a sleep of 1000ms before the smelt method. Quote Link to comment Share on other sites More sharing options...
Tom Posted March 16, 2015 Share Posted March 16, 2015 Just add a sleep long enough till it animates again if it will take 1 second for it to animate again add a sleep of 1000ms before the smelt method. You would have to return out of the method, a simple method like this would work better public boolean canAnimate(){ return System.currentTimeMillis() > (lastAnimation + 3000); } Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 16, 2015 Share Posted March 16, 2015 You would have to return out of the method, a simple method like this would work better public boolean canAnimate(){ return System.currentTimeMillis() > (lastAnimation + 3000); } Yes, that would indeed be a better solution. Quote Link to comment Share on other sites More sharing options...