SHOW:
|
|
- or go back to the newest paste.
1 | glass = peripheral.wrap("bottom") | |
2 | ||
3 | rednet.open( "back" ) | |
4 | ||
5 | - | -- We always reset when starting back up |
5 | + | -- Constants |
6 | - | glass.clear() |
6 | + | pos_x = 40 |
7 | pos_y = 55 | |
8 | - | -- Quarry status |
8 | + | pos_inc = 10 |
9 | color[on] = "0x2290000" | |
10 | color[off] = "0xFF0000" | |
11 | ||
12 | - | device = "" |
12 | + | -- Devices |
13 | local devices = {Quarry} | |
14 | - | rednet.broadcast( "get quarry" ) |
14 | + | |
15 | -- Device status | |
16 | - | sleep( 1 ) |
16 | + | local status = {} |
17 | for i, device in ipairs( devices ) do | |
18 | status[device] = glass.addText( pos_x, pos_y, device, status[off] ) | |
19 | pos_y = pos_y + pos_inc | |
20 | end | |
21 | ||
22 | - | if not device then |
22 | + | |
23 | ||
24 | while true do | |
25 | - | if i == "off" then |
25 | + | local command = "" |
26 | - | statusQuarry.setColor( 0x229000 ) |
26 | + | local device = "" |
27 | - | else |
27 | + | local status = "" |
28 | - | statusQuarry.setColor( 0xFF0000 ) |
28 | + | |
29 | - | end |
29 | + | |
30 | print( senderID .. ": " .. message ) | |
31 | ||
32 | for i in string.gmatch( message, "%S+" ) do | |
33 | - | sleep( 10 ) |
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" ) |