Hi,
I want to realize based on the timer script example following function:
-the offstate is an minimum brightness level of e.g. 25% (should be adjustable with an external object)
-maximum (on state) brightness level of e.g. 90% (should be adjustable with an external object)
-time should be adjustable with an external object
-during the time counts down, each X seconds the light dims down -10% until it's on the minimum level
-the whole function can be switch off (0% brightness)
My customer would like to illuminate an show room. The base illumination should be a brightness level of 50%. If somebody walks through the presentation the light triggers up to 95% until X seconds the motion sensors don't triggers motion again and dims the brightness level down to the default brightness of 50%.
At end of working day he completly switchs off the whole light.
Has somebody already realized such a function?
How it's the best way to handle such scripts. resident script or event based? I want to use it for up to 16 Light Circles...
Thank you forwards for any help :-)
I want to realize based on the timer script example following function:
-the offstate is an minimum brightness level of e.g. 25% (should be adjustable with an external object)
-maximum (on state) brightness level of e.g. 90% (should be adjustable with an external object)
-time should be adjustable with an external object
-during the time counts down, each X seconds the light dims down -10% until it's on the minimum level
-the whole function can be switch off (0% brightness)
My customer would like to illuminate an show room. The base illumination should be a brightness level of 50%. If somebody walks through the presentation the light triggers up to 95% until X seconds the motion sensors don't triggers motion again and dims the brightness level down to the default brightness of 50%.
At end of working day he completly switchs off the whole light.
Has somebody already realized such a function?
How it's the best way to handle such scripts. resident script or event based? I want to use it for up to 16 Light Circles...
Thank you forwards for any help :-)
Code:
-- maximum time that object can be on, in seconds
ontime = 4 * 60 * 60
-- current timestamp, in seconds
now = os.time()
-- get all objects with AutoOff tag
objects = grp.tag('AutoOff')
-- check all objects
for _, object in ipairs(objects) do
-- object is on
if toboolean(object.data) then
delta = now - object.updatetime
-- timer expired, turn off
if delta >= ontime then
object:write(0)
end
end
end