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 | print( "Adding " .. device .. " as " .. color["off"] ) | |
20 | status[device] = glass.addText( pos_x, pos_y, device, color["off"] ) | |
21 | pos_y = pos_y + pos_inc | |
22 | end | |
23 | ||
24 | while true do | |
25 | local command = "" | |
26 | local device = "" | |
27 | local status = "" | |
28 | ||
29 | senderID, message, distance = rednet.receive() | |
30 | print( senderID .. ": " .. message ) | |
31 | ||
32 | for i in string.gmatch( message, "%S+" ) do | |
33 | if not command then | |
34 | command = i | |
35 | elseif not device then | |
36 | device = i | |
37 | else | |
38 | status = i | |
39 | end | |
40 | end | |
41 | ||
42 | status[device].setColor( color[status] ) | |
43 | end | |
44 | ||
45 | rednet.close( "back" ) |