Search the Community
Showing results for tags 'lights'.
-
Purpose, Makes lights randomly change rgb colour and cycles them to give a breathing effect. Level: Lua beginner = cut and paste code, create filters unit start and system update in lua editor , DU = know how to link lights to a programming board Build You need 1 Programming Board(PB) and some lights. Connect the lights to the PB and name each slot in the lua editor (Ctrl L) you have connected l1 , l2 etc. If you don't want 8 then edit the source code and remove. code is below. Other stuff you can do : add a detector to autostart , change parameters in unit start to get the feel you like. -- copy and paste into unit start unit.hide() -- hides programming board -- remove these where you have not connected a light l1.activate() l2.activate() l3.activate() l4.activate() l5.activate() l6.activate() l7.activate() l8.activate() bClock = system.getTime() -- start clock origRgb = l1.getRGBColor() -- stores the colour of the original light if you want to reset lights on exit breathRate = 1 --export: rate of breathing Multiplier changeFrame = 1200 --export: frame colour and channel cycle rgbIndex = utils.round(math.random(3)) -- choose channel to breathe r = math.random(255) -- setup channels g = math.random(255) b = math.random(255) frameCount = 0 -- Copy and Paste into System update frameCount = frameCount + 1 if ( frameCount % changeFrame == 0 ) then --randomize rgb and channel r = math.random(255) g = math.random(255) b = math.random(255) rgbIndex = utils.round(math.random(3)) -- choose channel to breathe end nClock = system.getTime() local timeSeconds = ( nClock - bClock) local breath = utils.round(( math.exp( math.sin(timeSeconds * breathRate )) - 0.36787944 )* 108.0) if rgbIndex == 1 then r = breath elseif rgbIndex == 2 then g = breath else b = breath end -- set rgb colour of linked lights ,remove these where you have not connected a light l1.setRGBColor(r,g,b) l2.setRGBColor(r,g,b) l3.setRGBColor(r,g,b) l4.setRGBColor(r,g,b) l5.setRGBColor(r,g,b) l6.setRGBColor(r,g,b) l7.setRGBColor(r,g,b) l8.setRGBColor(r,g,b)
- 1 reply
-
- lua script
- lua
-
(and 2 more)
Tagged with:
-
So if data links can carry non-binary information (which I think they can, for screens for example), why not having a light with three inputs for 8-bit values (integers between 0 and 255), one for red, one for green and one for blue? We could have the lighting changing depending on the situation, for example red if the base is attacked or green the day and blue the night (light detectors btw?)