SHOW:
|
|
- or go back to the newest paste.
1 | local modem = peripheral.find("modem") | |
2 | local monitor = peripheral.wrap("front") | |
3 | ||
4 | monitor.clear() | |
5 | monitor.setCursorPos(1,1) | |
6 | monitor.setTextScale(0.5) | |
7 | term.clear() | |
8 | term.setCursorPos(1,1) | |
9 | - | repeat |
9 | + | print("Running...") |
10 | ||
11 | - | while rs.getAnalogInput("top") == 15 |
11 | + | |
12 | - | do rs.setOutput("right",true) |
12 | + | local function shift(side, mode, bgc, tc) |
13 | - | modem.transmit(2,3,"Full Power") |
13 | + | rs.setOutput(side,true) |
14 | - | monitor.setBackgroundColor(colors.green) |
14 | + | modem.transmit(2,3,mode) |
15 | - | monitor.setTextColor(colors.white) |
15 | + | monitor.setCursorPos(1,1) |
16 | - | print("Automated Power Control") |
16 | + | monitor.clear() |
17 | - | monitor.setCursorPos(8, 4) |
17 | + | monitor.setBackgroundColor(bgc) |
18 | - | monitor.write("Automated Power Control") |
18 | + | monitor.setTextColor(tc) |
19 | - | print("-=-=-=-=-=-=-=-=-=-=-=-") |
19 | + | monitor.setCursorPos(8, 4) |
20 | - | monitor.setCursorPos(8, 5) |
20 | + | monitor.write("Automated Power Control") |
21 | - | monitor.write("-=-=-=-=-=-=-=-=-=-=-=-") |
21 | + | monitor.setCursorPos(8, 5) |
22 | - | print("Full Power Mode Active") |
22 | + | monitor.write("-=-=-=-=-=-=-=-=-=-=-=-") |
23 | - | monitor.setCursorPos(8, 6) |
23 | + | monitor.setCursorPos(8, 6) |
24 | - | monitor.write("Full Power Mode Active") |
24 | + | monitor.write(mode) |
25 | - | sleep(1) |
25 | + | sleep(1) |
26 | - | rs.setOutput("right",false) |
26 | + | rs.setOutput(side,false) |
27 | term.setCursorPos(1,3) | |
28 | end | |
29 | ||
30 | while rs.getInput("front") == false | |
31 | do | |
32 | - | while rs.getAnalogInput("top") == 14 |
32 | + | |
33 | - | do rs.setOutput("back",true) |
33 | + | local speed = rs.getAnalogInput("top") |
34 | - | modem.transmit(2,3,"Low Power") |
34 | + | |
35 | - | monitor.setBackgroundColor(colors.yellow) |
35 | + | if speed == 15 |
36 | - | monitor.setTextColor(colors.black) |
36 | + | then |
37 | - | print("Automated Power Control") |
37 | + | shift ("right", "Full Power", colors.green, colors.white) |
38 | - | monitor.setCursorPos(8, 4) |
38 | + | |
39 | - | monitor.write("Automated Power Control") |
39 | + | |
40 | - | monitor.setCursorPos(8, 5) |
40 | + | if speed == 14 |
41 | - | print("-=-=-=-=-=-=-=-=-=-=-=-") |
41 | + | then |
42 | - | monitor.write("-=-=-=-=-=-=-=-=-=-=-=-") |
42 | + | shift ("back", "Low Power", colors.blue, colors.white) |
43 | - | print("Low Power Mode Active") |
43 | + | |
44 | - | monitor.setCursorPos(8, 6) |
44 | + | |
45 | - | monitor.write("Low Power Mode Active") |
45 | + | if speed == 9 |
46 | - | sleep(1) |
46 | + | then |
47 | - | rs.setOutput("back",false) |
47 | + | shift ("left", "Standby", colors.yellow, colors.black) |
48 | end | |
49 | ||
50 | if speed == 8 | |
51 | then | |
52 | shift ("bottom", "Offline", colors.red, colors.white) | |
53 | - | while rs.getAnalogInput("top") <= 13 |
53 | + | |
54 | - | do rs.setOutput("left",true) |
54 | + | |
55 | - | modem.transmit(2,3,"Standby") |
55 | + | end |