Good day, everyone!
I am currently making a weather simulation as a hobby project, with focus on the dynamic and smooth transition between different weather situations (f.e. clear sky slowly filling up with many clouds turning dark.)
For this I have attributes inside of my responsible WeatherTranistioner script for the desired weather conditions set by other scripts, like cloud density and cloud coverage. For the actual weather situation I read the values from the responsible weather objects directly (such as workspace.Terrain.Clouds.Cover).
A for-loop, executed constantly by a while-loop, then compares the values dynamically via tables and calls another method if the desired- and actual values do not match up.
The tables should look something like in this example:
Clouds = workspace.Terrain.Clouds
singularAttributeTable = {CloudDensity = {Clouds.Density, script:GetAttribute("DesiredCloudDensity")}, CloudCover = {Clouds.Cover, script:GetAttribute("DesiredCloudCover")}}
However, the problem I face with this is that the actual current value of the attributes is saved in the table, not the references to the values.
That’s why my current script looks far more ugly and uses a lot of [] brackets, such as value[1][value[2]] as I save the location name of the object and the key name of the value. A working version of this can be cloned here: Weather Demo - Roblox (version 5/20/2022, note that I didn’t know about Attributes at that point and instead used global variables hehe.)
So, is there any effective way to save the value reference, so I can dynamically read and change it? Or should I instead just save strings that the script then resolves to the value?
Many thanks in advance!