View difference between Paste ID: VY2tUpuC and 0kgZw4EJ
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
8
pos_inc = 10
9
local color = {}
10
color["on"] = 0x229000
11
color["off"] = 0xFF0000
12
13
-- Devices
14
local devices = { "Quarry" }
15
16
-- Device status
17
local status = {}
18
for i, device in ipairs( devices ) do
19
  status[device] = glass.addText( pos_x, pos_y, device, color["off"] )
20
  pos_y = pos_y + pos_inc
21
end
22
23
while true do
24
  local command = ""
25
  local device = ""
26
  local status = ""
27
28
  senderID, message, distance = rednet.receive()
29
  print( senderID .. ": " .. message )
30
31-
  local string = {}
31+
32-
  string = split( message, " " )
32+
33-
  command = string[1]
33+
34-
  device = string[2]
34+
35-
  status = string[3]
35+
36
    else
37
      status = i
38
    end
39
  end
40
  
41
  if not device then
42
    print( "Something fubared the rednet message: " .. message )
43
  else
44
    status[device].setColor( color[status] )
45
  end
46
end
47-
  status[device].setColor( color[status] )
47+
48
rednet.close( "back" )