Script for blinking lights

I want a script that automatically sets the intensity of a light source randomly between 20 and 200 every 3 frames within an animation. The script doesn't trigger any error but the intensity isn't modified at all. What's wrong ?
Post edited by linoge8888 on
Comments
I tried but impossible to find the exact name of the parameter. I'm a beginniner, by the way.
You need to make two corrections.
The "Intensity" is displayed as a percentage, but the actual value you set is a real value where 100% equals 1.
If you want to set the "Intensity" to a value between 20% and 200%, the argument you give to setValue should be a real number between 0.2 and 2.
Therefore, getRandomIntensity() can be rewritten as follows, for example.
DzTime is defined in ticks.
There are 4800 ticks per second. In the case of 30 FPS, there are 160 ticks (4800 / 30) per frame.
Therefore, the part where you calculate the time should be rewritten as follows
With the two corrections above, your code should be working correctly.
Thank you very much!
Note that there is no beenfit, and potential confusion, from declaring the variables inside the loop - they don't get created and destroyed on each iteration, they last (and are accessible) as long as the function is runing.
You can get the actual start from frame directly, so if that is what you want it may be more flexible to use http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/animating/scene_time/start . Of course if this is a frame during the playrange then setting the value directly may well make more sense.