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