View difference between Paste ID: g11Da3dc and AqAUCVcP
SHOW: | | - or go back to the newest paste.
1
local reactor, lMon, rMon
2
reactor = peripheral.wrap("BigReactors-Reactor_0")
3
lMon = peripheral.wrap("left")
4
rMon = peripheral.wrap("right")
5
6
lMon.setTextScale(0.5)
7
rMon.setTextScale(0.5)
8
lMon.clear()
9
rMon.clear()
10
11
print("Running Reactor Monitor...")
12
13
function UpdateScreens(stored, lastTick, reactorOn, rods)
14
	local storedPerc 
15
	storedPerc = math.floor((stored / 10000) * 100)
16
	
17
	lMon.clear()
18
	lMon.setCursorPos(1,1)
19
	lMon.write("Stored:")
20
	lMon.setCursorPos(1,2)
21
	lMon.write(stored .. "k " .. storedPerc .. "%")
22
	lMon.setCursorPos(1,3)
23
	lMon.write("Current:")
24
	lMon.setCursorPos(1,4)
25
	lMon.write(lastTick)
26
	
27
	rMon.clear()
28
	rMon.setCursorPos(1,1)
29
	rMon.write("Status:")
30
	rMon.setCursorPos(1,2)
31
	
32
	if reactorOn then
33
		rMon.write("Active")
34
	else
35
		rMon.write("Inactive")
36
	end
37
	
38
	rMon.setCursorPos(1,3)
39
	rMon.write("Rods:")
40
	rMon.setCursorPos(1,4)
41
	for k,v in pairs(rods) do
42
		rMon.write(v .. "% ")
43
	end
44
end
45
46
function PollReactor()
47
	local energyStored, energyLastTick, reactorOn, rods
48
	
49
	energyStored = math.floor(reactor.getEnergyStored() / 1000)
50
	energyLastTick = math.floor(reactor.getEnergyProducedLastTick())
51
	reactorOn = reactor.getActive()
52
	
53
	rods = {}
54
	rodCount = reactor.getNumberOfControlRods()
55
	
56
	for i=1,rodCount,1 do
57
		rods[i] = reactor.getControlRodLevel(i - 1)
58
	end
59
	
60
	UpdateScreens(energyStored, energyLastTick, reactorOn, rods)
61
end
62
63
while true do
64
	PollReactor()
65
	os.sleep(1)
66
end