-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreactor.lua
More file actions
77 lines (66 loc) · 1.71 KB
/
reactor.lua
File metadata and controls
77 lines (66 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
local reactor = peripheral.wrap("back")
local monitor = peripheral.wrap("top")
monitor.clear()
highestRFpT = 0
threshold = 0.9
while(1) do
y = 1
-- Is active
monitor.setCursorPos(1, y)
if(reactor.getActive() == true) then
monitor.write("ON")
else
monitor.write("OFF")
end
y = y + 1
-- RF stored / Max / Percentage
monitor.setCursorPos(1, y)
currentEnergy = reactor.getEnergyStored()
monitor.write(tostring(currentEnergy))
monitor.write("RF/")
maxEnergy = reactor.getEnergyCapacity()
monitor.write(tostring(maxEnergy))
monitor.write(" RF: ")
pRF = tostring(currentEnergy/maxEnergy*100)
pRF = string.format("%3.2f",pRF)
monitor.write(pRF)
monitor.write("%")
y = y + 1
-- Fuel / Max / Percentage
monitor.setCursorPos(1, y)
currentFuel = reactor.getFuelAmount()
monitor.write(tostring(currentFuel))
monitor.write("/")
maxFuel = reactor.getFuelAmountMax()
monitor.write(tostring(maxFuel))
monitor.write(" Fuel: ")
pFuel = tostring(currentFuel/maxFuel*100)
pFuel = string.format("%3.2f",pFuel)
monitor.write(pFuel)
monitor.write("%")
y = y + 1
-- RF/t
monitor.setCursorPos(1, y)
RFgeneration = reactor.getEnergyProducedLastTick()
monitor.write(tostring(math.floor(RFgeneration)))
monitor.write(" RF/t")
y = y + 1
if(RFgeneration > highestRFpT) then
highestRFpT = RFgeneration
end
-- highest RF/t
monitor.setCursorPos(1, y)
monitor.write(tostring(math.floor(highestRFpT)))
monitor.write(" peak RF/t")
y = y + 1
-- Controller
if( (currentEnergy / maxEnergy) > threshold ) then
reactor.setActive(false)
threshold = 0.9
else
reactor.setActive(true)
threshold =0.95
end
sleep(0.5)
monitor.clear()
end