View difference between Paste ID: nvyn6tnN and ZUDKLf6b
SHOW: | | - or go back to the newest paste.
1
glass = peripheral.wrap( "bottom" )
2
3
rednet.open( "back" )
4
5
-- Constants
6
pos_x = 40
7-
pos_y = 55
7+
pos_y = 45
8
pos_inc = 10
9-
local color = {}
9+
color = {}
10
color["on"] = 0x229000
11
color["off"] = 0xFF0000
12
13
-- Devices
14-
local devices = { "Quarry" }
14+
15
-- Device status
16
status = {}
17-
local status = {}
17+
function addStatus( device, mode )
18-
for i, device in ipairs( devices ) do
18+
19
  pos_y = pos_y + pos_inc
20
end
21
22
while true do
23
  local command = ""
24
  local device = ""
25
  local mode = ""
26-
  local status = ""
26+
27
  senderID, message, distance = rednet.receive()
28
  print( senderID .. ": " .. message )
29
30
  for i in string.gmatch( message,  "%S+" ) do
31
    if command ~= "" and device ~= "" then
32
      mode  = i
33-
      status = i
33+
34
    if command ~= "" and device == "" then
35
      device = i
36
    end
37
    if command == "" and device == "" then
38
      command = i
39
    end
40
  end
41
  
42
  if nil status[device] then
43-
  if not device then
43+
    addStatus( device, mode )
44-
    print( "Something fubared the rednet message: " .. message )
44+
45
    status[device].setColor( color[mode] )
46-
    status[device].setColor( color[status] )
46+
47
end
48
49
rednet.close( "back" )