Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modem = peripheral.wrap("back")
- local lamps = modem.getNamesRemote()
- local time = 0
- local frequency = 0.1
- local phaseMod = 0.3
- local delay = 0.08
- function rgbToHex(rgb)
- local hexadecimal = '0x'
- for key, value in pairs(rgb) do
- local hex = ''
- while(value > 0)do
- local index = math.fmod(value, 16) + 1
- value = math.floor(value / 16)
- hex = string.sub('0123456789ABCDEF', index, index) .. hex
- end
- if(string.len(hex) == 0)then
- hex = '00'
- elseif(string.len(hex) == 1)then
- hex = '0' .. hex
- end
- hexadecimal = hexadecimal .. hex
- end
- return hexadecimal
- end
- function RGBSine(redPhase,bluePhase,greenPhase)
- local red = math.sin(frequency*time + (redPhase*phaseMod) + 0) * 127 + 128
- local green = math.sin(frequency*time + (bluePhase*phaseMod) + 2) * 127 + 128
- local blue = math.sin(frequency*time + (greenPhase*phaseMod) + 4) * 127 + 128
- local colores = rgbToHex({red,green,blue})
- return tonumber(colores)
- end
- while true do
- sleep(delay)
- for i=1,#lamps do
- modem.callRemote(tostring(lamps[i]), "setColor", RGBSine(i,i,i))
- end
- time = time+1
- end
Add Comment
Please, Sign In to add comment