View difference between Paste ID: 0kgZw4EJ and nEmrrpvH
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 = {}
32
  string = split( message, " " )
33
  command = string[1]
34
  device = string[2]
35
  status = string[3]
36
37
  for i in string.gmatch( message,  "%S+" ) do
38
    if not command then
39
      command = i
40
    elseif not device then
41
      device = i
42
    else
43
      status = i
44
    end
45
  end
46
  
47
  status[device].setColor( color[status] )
48
end
49
50
rednet.close( "back" )