1) Give a description of the problem
I am attempting to reduce some code in a piston for tracking when someone is awake or asleep. I have a button named after each person, and a boolean global variable which keeps track of if they are awake or not, also based on their name. Using an if statement, I can check if a button is pressed/held, and if the corresponding global variable is correctly set. The down side is I end up with 1 condition per person.
Seeing as how the name of the button that was pressed would tell me which global variable to check, I wanted to compress this to pragmatically determine the correct global variable to use based on the name of the device that was activated. I can get to the point where I write the NAME of the global variable out in the info log by parsing the device string and building the known global variable name. I even saved it in a local variable. However I can’t figure out a way to the SET a variable, if the variable that will be manipulated could change depending on the input.
2) What is the expected behavior?
When the button is “pushed”, and the global varriable which corrosponds to it is false, set the global variable to true. (in my example, this would be waking up)
3) What is happening/not happening?
It is correctly saving a local variable which has the name of the global variable tied to the button that was pressed, and using “bool” function I can check if it is false. Right now I can’t figure out what to put in the then statement to now set it to true. All “set variable” functions I see make me choose one global varaible. I want to set the global variable who’s name is now in the local variable “GlobalVariable” to True. But since the determination of which global variable is being altered is dependent on the device, I need set function that I can pass a string to rahter than picking one hard coded.
**4) Post a Green Snapshot of the piston![image|45x37]
**5) Attach any logs
No logs, since I am stuck as to how to do the setting…