SHOW:
|
|
- or go back to the newest paste.
1 | reactor = peripheral.wrap("back") | |
2 | mon = peripheral.wrap("top") | |
3 | mon.clear() | |
4 | mon.setBackgroundColor(colors.blue) | |
5 | color = blue | |
6 | ||
7 | --power = 0 | |
8 | --fuel = 0 | |
9 | --maxFuel = 0 | |
10 | --rf = 0 | |
11 | ||
12 | function calc(min, max) | |
13 | ||
14 | percent = 53 / max | |
15 | ||
16 | x = percent * min | |
17 | ||
18 | --print("percent: "..percent.." x: "..x) | |
19 | ||
20 | return 53, x | |
21 | ||
22 | end | |
23 | ||
24 | function progress(current, max, pos1, pos2) | |
25 | ||
26 | --Power | |
27 | maxX,x = calc(current,max) | |
28 | for i=0,3 do | |
29 | for z=1,maxX do | |
30 | mon.setCursorPos(pos1+z,pos2+i) | |
31 | if z <= x then | |
32 | mon.setBackgroundColor(colors.green) | |
33 | else | |
34 | mon.setBackgroundColor(colors.white) | |
35 | end | |
36 | ||
37 | mon.write(" ") | |
38 | end | |
39 | end | |
40 | end | |
41 | ||
42 | function draw(color) | |
43 | mon.clear() | |
44 | ||
45 | power = reactor.getEnergyStored() | |
46 | maxPower = 10000000 | |
47 | fuel = reactor.getFuelAmount() | |
48 | maxFuel = reactor.getFuelAmountMax() | |
49 | rf = reactor.getEnergyProducedLastTick() | |
50 | maxRf = 10000 | |
51 | ||
52 | mon.setCursorPos(28,1) | |
53 | mon.write("Reactor") | |
54 | ||
55 | mon.setCursorPos(2,4) | |
56 | mon.write("Power:") | |
57 | mon.setCursorPos(1,5) | |
58 | mon.write(math.floor(power/1000).."kRF") | |
59 | ||
60 | mon.setCursorPos(2,10) | |
61 | mon.write("Fuel:") | |
62 | mon.setCursorPos(1,11) | |
63 | mon.write(math.floor((fuel/maxFuel)*100).."%") | |
64 | ||
65 | mon.setCursorPos(2,16) | |
66 | mon.write("RF/t:") | |
67 | mon.setCursorPos(1,17) | |
68 | mon.write(math.floor(rf/1000).."kRF/t") | |
69 | ||
70 | progress(power,maxPower,7,3) | |
71 | progress(fuel,maxFuel,7,9) | |
72 | progress(rf,maxRf,7,15) | |
73 | ||
74 | if reactor.getActive() == true then | |
75 | mon.setBackgroundColor(colors.blue) | |
76 | else | |
77 | mon.setBackgroundColor(colors.red) | |
78 | end | |
79 | end | |
80 | ||
81 | while true do | |
82 | ||
83 | draw(color) | |
84 | ||
85 | if reactor.getEnergyStored() >=9000000 then | |
86 | reactor.setActive(false) | |
87 | mon.setBackgroundColor(colors.red) | |
88 | color = red | |
89 | end | |
90 | ||
91 | if reactor.getEnergyStored() <= (10000000/4) then | |
92 | reactor.setActive(true) | |
93 | mon.setBackgroundColor(colors.blue) | |
94 | color = blue | |
95 | end | |
96 | ||
97 | sleep(2) | |
98 | end |