Help Make my Script more compact?

  1. No biggie… i just wondered. So, if i had the choice to be in nature or in the forum, i’d go hiking too. Hope you had a nice trip
  2. Good to know. :+1:
  3. I noticed that if everything was based on arrays, it worked. Therefore i had to put the OnTimePassing stuff into its own function, so that i could use arrays and the corresponding index number. The diffrence between declaring a variable in the “var” block or within a function is that the definition in the “var” block makes it a “global” variable (is available in the whole script without further definition), but a definition within a function makes it “local” (only available within this particular function block).
    So, theoretically i could have used “i” in all the function blocks as it’s always a local variable - nothing that has to be seen outside of its own function. But i decided the “Ai” (like ArrayIndex) would be a better choice for its purpose (i also could have named it “Martha”… wouldn’t make a diffrence :wink: )
    Maybe my question about Arrays in this sub forum (i also needed to have some clarification) might help you understand the issue we faced by mixing the separate variables and the arrays (of which i thought they would point to the varaibles that we used to define them - but they actually don’t):
    Understanding Arrays - #3 by schamass
  4. Yes, that’s right… the names after the “from” are used to identify the widgets to be “listened to” and the one that’s been triggered can then be used by its name (parameter “widget”) or by its index from the names-row (parameter “index”).
  5. Hm… that’s something i’d have to have a closer look at…
    Some options i can spontaniously think of…
    You could try to only call the SetFading() if the according widget gets switched “ON” (newValue >0.5), so if it changes its state by being switched OFF, nothing will happen.
    You could experiment with the “default value” of the widget’s properties
    Or you could use another set of variables to store the starting values on initialization, but which you don’t change anymore within the code, so you’d always have a “fallback”. This could then be re-written to the widgets each time for “On Activation” of the rackspace (whenever you activate it).
    Or an additional set of widgets which would only represent the starting values and a separate widget/function to store the actual state to them, and then “On Activation” the values of the “buffer widgets” would be transferred to the “real ones”- that way you could change things on the fly too.