Hi everyone. I have a piston (SWITCH) that is executed by a virtual switch, it sets a global boolean variable ALL_ON as TRUE and then executes another piston (MOTORS) sending some arguments.
This second piston (MOTORS) is not subscribed to events (it is only executed by the SWITCH piston) and has a restriction that only completes its actions if ALL_ON variable is TRUE. (This is because it has a for loop and I don’t want the loop to continue its course of action if I turn off the switch in the middle of the actions, which take around 1 minute in total).
I’ve been having a problem and enabled the logs to analyze it. It seems that sometimes when the MOTORS piston is started, the first comparison it makes [Comparison (boolean) false is (boolean) true = false (1ms)] is resulting false, and this line changes in the logs when the piston works, so I’m assuming that at the time this piston reads the global variable it hasn’t been yet updated. Does this make sense?
I’ve been told here before that global variables are “slower” than arguments or local variables, could this be the problem?
If so, would I need to add a WAIT in the SWITCH piston, between the ALL_ON variable being written and the MOTOR piston being executed so that I leave some spare time for the ALL_ON variable to be updated?
I want confirmation if this makes sense and if so, how much of a delay would you add? This piston works fine 90% of the times.
I went with this global variable because I tried other methods to make the piston “stop” in the middle of the action and they didn’t work. This method works fine most of the times but has this only problem, so I’d prefer to stick with this, but anyway all comments are appreciated
Thanks,
Rodrigo.