Script example 5: Daylight synchronized spot - Daglicht gesynchroniseerde spot

Freek-Jan Buijsman
Freek-Jan Buijsman Administrator
December 2017 aangepast in Native scripts
#Example for synchronizing spots with the daylight
#This script starts by calculating the maximum sunlight intensity from 3 sides: east, south and west.
$MAXSUN = 2BYTE(3/Sunlight East)
IF 2BYTE(4/Sunlight South)>$MAXSUN
$MAXSUN = 2BYTE(4/Sunlight South)
IF 2BYTE(5/Sunlight West)>$MAXSUN
$MAXSUN = 2BYTE(5/Sunlight West)
#With this maximum we use a formula to reduce this number to a reasonable percentage. For this example we calculate this using the square root of the maximum, divided by 4.
$LIGHTX = ($MAXSUN ^ (1/2))/4
#Maximize the level to 100
IF ($LIGHTX>100)
$LIGHTX = 100
#Set the light to the calculated level
SET BYTE(21/Spots) TO $LIGHTX
#Wait for 1 minute and then restart
#This synchronises the spot’s light level to the sun intensity
WAIT 1 MIN
RESTART