Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- glass = peripheral.wrap( "bottom" )
- rednet.open( "back" )
- -- Constants
- pos_x = 40
- pos_y = 45
- pos_inc = 10
- color = {}
- color["on"] = 0x229000
- color["off"] = 0xFF0000
- -- Devices
- -- Device status
- status = {}
- function addStatus( device, mode )
- status[device] = glass.addText( pos_x, pos_y, device, color["off"] )
- pos_y = pos_y + pos_inc
- end
- while true do
- local command = ""
- local device = ""
- local mode = ""
- senderID, message, distance = rednet.receive()
- print( senderID .. ": " .. message )
- for i in string.gmatch( message, "%S+" ) do
- if command ~= "" and device ~= "" then
- mode = i
- end
- if command ~= "" and device == "" then
- device = i
- end
- if command == "" and device == "" then
- command = i
- end
- end
- if nil status[device] then
- addStatus( device, mode )
- else
- status[device].setColor( color[mode] )
- end
- end
- rednet.close( "back" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement