Camaro Posted January 9, 2019 Share Posted January 9, 2019 So when I stop a script in the middle of a ConditionalLoop, the loop will continue well after the script has stopped. I can tell by text strings continually getting posted to the log that I call from inside the loop. [INFO][Bot #1][01/08 11:19:59 PM]: Here [INFO][Bot #1][01/08 11:19:59 PM]: Here [INFO][Bot #1][01/08 11:19:59 PM]: Here [WARN][Bot #1][01/08 11:20:01 PM]: Event executor is taking too long to suspend; terminating now... [ERROR][Bot #1][01/08 11:20:01 PM]: Caught thread death in EventExecutor [INFO][Bot #1][01/08 11:20:01 PM]: Script Copper miner has exited! [INFO][Bot #1][01/08 11:20:43 PM]: Here [INFO][Bot #1][01/08 11:20:43 PM]: Here [INFO][Bot #1][01/08 11:20:44 PM]: Here Are there certain steps I should take to properly stop a script? Quote Link to comment Share on other sites More sharing options...
NoxMerc Posted January 10, 2019 Share Posted January 10, 2019 Do you create new Threads inside of onLoop? If so you'll need probably want to interrupt them by overring the script's onStop method. Alternatively, what you can do is use the script's async event system. I haven't used it personally, but if it's handholdy enough it'll track your Thread references for you and terminate them when the script ends. Quote Link to comment Share on other sites More sharing options...
liverare Posted January 10, 2019 Share Posted January 10, 2019 (edited) The API is horribly undocumented when it comes to internal stuff like this, so it's pretty much guess work. Try something like this: /* * ConditionalLoop isn't documented in the API. * Parameters: * 1. Bot * 2. Some random unspecified integer that's perhaps the number of cycles * before the loop ends. 0 = infinite? */ new ConditionalLoop(bot, 0) { @Override public int loop() { // your code here... return // probably -1 or 0 to stop, then anything else = sleep time? } }; Hopefully, by specifying the 'bot', the conditional loop will pause/suspend/die when the script does too, because you can find that out from the bot: private boolean isScriptRunning() { return bot.getScriptExecutor().isRunning(); } Edited January 10, 2019 by liverare Quote Link to comment Share on other sites More sharing options...
Camaro Posted January 12, 2019 Author Share Posted January 12, 2019 @Override public int onLoop() throws InterruptedException { new ConditionalLoop(bot, 30000) { @Override public int loop() { log("Running"); return 300; } @Override public boolean condition() { return true; } }.start(); return 600; } Just a simple conditional. Goes way past the 30 second timeout It is probably better to use an Event anyway. Quote Link to comment Share on other sites More sharing options...