On a most simplistic level, Iâd add an extra function that sets the parameter values:
def setlight(vals):
op('level25').par.opacity = vals[0]
op('Fresnels').par.const0value = vals[1]
... and so on. ..
And then in the onValueChange() function, call setlights():
if val == 0:
setlights([1, .05, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
else:
setlights([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
This at least makes certain that every parameter gets touched each time (note that after your if val == 1
youâre referencing op level26 which you donât do above, that means level26 gets set but never unset.
However, IMO the approach could be improved upon by using a pair of DAT tables, one that is a list of all lights and if theyâre on or off, and the second table that is a list of opnames, parnames, offvalue and onvalues. Then your code would iterate through the two tables and for each light, see if itâs 0 or 1, and then iterate through each line of the second DAT and set the op/par/value based on the âonâ or âoffâ column.
The advantage of the DAT table approach is you can see all your numbers changing dynamically all in one place. You might even want more than one light on at a given time, or ramp lights up or down. The result could be a third DAT table that is the full set of parameters and values.