Jack Shep Posted November 13, 2018 Posted November 13, 2018 I have an if statement inside of my onLoop which contains all of the code that would normally be in the onLoop. The only way the code will run is if "started" equals "true", and the only place "started" is changed from "false" to "true" is inside of the action listener for my start button in the GUI. However, about 25% of the time the code inside of onLoop and the if statement runs even if you haven't hit "Start" in the GUI. Using the search tool I've found nowhere else in my code that changes "started" to true besides for that action listener. I don't know what to do.
Juggles Posted November 14, 2018 Posted November 14, 2018 Use paint and see if the action is returning true sometimes
Jack Shep Posted November 14, 2018 Author Posted November 14, 2018 45 minutes ago, Juggles said: Use paint and see if the action is returning true sometimes I'll try this, but if it's returning true sometimes for no reason, how would I fix that?
Dot Posted November 14, 2018 Posted November 14, 2018 Move your check to onStart() and remove the if from your onLoop(). if (!started) { stop(); return; }
liverare Posted November 14, 2018 Posted November 14, 2018 (edited) I have ran into similar problems in the past that I believe were caused by caching issues between script executions. However, it would be worth seeing your code and for me to test whether I encounter the same problem. Edited November 14, 2018 by liverare
Eagle Scripts Posted November 14, 2018 Posted November 14, 2018 (edited) If you're saving the isStarted boolean as a static and you're using this in a local script, you need to hit the refresh button on the script selector once to make sure all the static variables are being 'reset'. Edited November 14, 2018 by Eagle Scripts
Jack Shep Posted November 19, 2018 Author Posted November 19, 2018 (edited) On 11/14/2018 at 7:51 AM, Eagle Scripts said: If you're saving the isStarted boolean as a static and you're using this in a local script, you need to hit the refresh button on the script selector once to make sure all the static variables are being 'reset'. I need to refresh the script selector every time I run the script but this worked. However is this only because it's a local script? If it was an SDN script or a private script would it not have the issue? Also is there a way to fix this issue with code? Edited November 19, 2018 by Jack Shep