Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- colorTable = {}
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.lime)
- print("Opening rednet on side top")
- rednet.open("top")
- function colorToHex(rgb)
- local hexadecimal = ''
- 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 sendColor(hex)
- rednet.broadcast(hex,"Lamp")
- end
- while true do
- red = 3
- green = 3
- blue = 3
- colorTable["r"] = red
- colorTable["g"] = green
- colorTable["b"] = blue
- hex = colorToHex(colorTable)
- sendColor(hex)
- sleep(0)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement