Advanced List Types in Global Variables


#1

It would be incredibly useful to be able to store advanced list types in global variables. I’m guessing that the reason this hasn’t been implemented is that the developers don’t want people trying to simulate databases using global variables, but for quick little tasks, it would be very helpful.

For instance, I’d just like to store a string index based array of datetimes showing the arrival times of users. This works just fine in a local variable:

Annotation%202020-01-15%20083605

If I could store a similar list of datetime objects in a global variable, I could update it and use those values across pistons, making life way easier.


#2

Why not just drop the array, and dump the three times into three global variables?


Pro Tip:

Keep in mind that if other pistons are using those times as a condition, then you are good to go… BUT… if other pistons are using those times as a trigger, then they will trigger at the old (previous) times unless the piston runs once prior to the new time.

(Normally, pistons only see the changes to a global once the piston is already running)


#3

That would definitely work, but will require some extra coding and just isn’t as elegant. My example was for 3 people, but you could just as easily have an array of device states that is indexed by the device name, for instance. Something like that might contain a lot more than three values. I was just hoping to be able to store and retrieve values using something dynamic like a device or person name, rather than having to define a ton of individual variables.


#4

You can store multiple dataPoints into a single global string, but this requires parsing the data when needed. Keeping them separate is likely the best we are going to get until webCoRE v3 gets a few updates…