157 lines
4.1 KiB
Plaintext
157 lines
4.1 KiB
Plaintext
AUTOMATIC = true
|
|
EJECT = true
|
|
|
|
function reactorWrite(monitor, reactor)
|
|
monitor.clear()
|
|
|
|
monitor.setCursorPos(1,1)
|
|
active = tostring(reactor.getActive())
|
|
monitor.write("Active: ".. active)
|
|
|
|
currentFuel = reactor.getFuelAmount()
|
|
fuelMax = reactor.getFuelAmountMax()
|
|
fuel = tostring((currentFuel / fuelMax)*100)
|
|
monitor.setCursorPos(1,2)
|
|
monitor.write("Fuel: ".. fuel.."%")
|
|
|
|
energy = tostring(reactor.getEnergyProducedLastTick())
|
|
monitor.setCursorPos(1,3)
|
|
monitor.write("Energy: ".. energy.." RF")
|
|
|
|
curStore = reactor.getEnergyStored()
|
|
maxEnergy = 10000000
|
|
energyStore = tostring((curStore / maxEnergy)*100)
|
|
monitor.setCursorPos(1,4)
|
|
monitor.write("Energy Buffer: "..energyStore.."%")
|
|
|
|
if AUTOMATIC then
|
|
if tonumber(energyStore) > 95 then
|
|
reactor.setActive(false)
|
|
monitor.setBackgroundColor(colors.red)
|
|
end
|
|
if tonumber(energyStore) < 95 then
|
|
reactor.setActive(true)
|
|
monitor.setBackgroundColor(colors.blue)
|
|
end
|
|
end
|
|
|
|
caseTemp = tostring(reactor.getCasingTemperature())
|
|
monitor.setCursorPos(1,5)
|
|
monitor.write("Temperature: "..caseTemp)
|
|
|
|
--[[Fuel Bar Graph]]--
|
|
barWidth = math.floor((tonumber(fuel)/100)*20)
|
|
makeBarGraph("Fuel: ", 10, 8, 19, 2, false, barWidth, monitor)
|
|
|
|
--[[Energy Bar Graph]]--
|
|
barWidth = math.floor((tonumber(energyStore)/100)*20)
|
|
makeBarGraph("Energy: ", 10, 11, 19, 2, false, barWidth, monitor)
|
|
|
|
--[[Produced Bar Graph]]--
|
|
barWidth = math.floor((tonumber(energy)/1000000)*20)
|
|
makeBarGraph("Produced: ", 10, 14, 19, 2, false, barWidth, monitor)
|
|
|
|
--[[Temperature Bar Graph]]--
|
|
barWidth = math.floor((tonumber(caseTemp)/2000)*20)
|
|
makeBarGraph("Temp: ", 10, 17, 19, 2, true, barWidth, monitor)
|
|
|
|
--[[On/off button]]--
|
|
if reactor.getActive() then
|
|
color = colors.white
|
|
label = "ON"
|
|
else
|
|
color = colors.black
|
|
label = "OFF"
|
|
end
|
|
makeButton(label, 31, 1,9, 5, color)
|
|
|
|
--[[Auto Button]]--
|
|
if AUTOMATIC then
|
|
color = colors.white
|
|
label = "AUTOMATIC"
|
|
else
|
|
color = colors.black
|
|
label = "MANUAL"
|
|
end
|
|
makeButton(label, 31, 8,9, 5, color)
|
|
|
|
--[[Eject/Accept]]--
|
|
if EJECT then
|
|
color = colors.white
|
|
label = "EJECT"
|
|
else
|
|
color = colors.black
|
|
label = "INTAKE"
|
|
end
|
|
makeButton(label, 31, 15,9, 5, color)
|
|
end
|
|
|
|
--[[makes a bar graph for a big reactor]]--
|
|
--[[str, num, num, num, num, num, bool, monitor]]--
|
|
function makeBarGraph(label, xpos, ypos, width, height, inverted, barWidth, monitor)
|
|
|
|
--[[stops flickering]]--
|
|
barStart = xpos + barWidth
|
|
barEnd = width - barWidth
|
|
|
|
--[[makes the label]]--
|
|
monitor.setCursorPos(1, ypos)
|
|
monitor.write(label)
|
|
|
|
--[[makes the first bar]]--
|
|
firstBar = window.create(monitor, xpos, ypos, width, height)
|
|
if inverted then
|
|
firstBar.setBackgroundColor(colors.green)
|
|
else
|
|
firstBar.setBackgroundColor(colors.orange)
|
|
end
|
|
firstBar.clear()
|
|
|
|
--[[makes the middle bar]]--
|
|
middleBar = window.create(monitor, xpos+2, ypos, width-2, height)
|
|
middleBar.setBackgroundColor(colors.yellow)
|
|
middleBar.clear()
|
|
|
|
--[[makes the last bar]]--
|
|
endBar = window.create(monitor, xpos+8, ypos, width-8, height)
|
|
if inverted then
|
|
endBar.setBackgroundColor(colors.orange)
|
|
else
|
|
endBar.setBackgroundColor(colors.green)
|
|
end
|
|
endBar.clear()
|
|
|
|
--[[makes the variable bar]]--
|
|
varBar = window.create(monitor, barStart, ypos, barEnd, height)
|
|
varBar.setBackgroundColor(colors.black)
|
|
varBar.clear()
|
|
|
|
monitor.setCursorPos(xpos, ypos+2)
|
|
monitor.write("0%")
|
|
monitor.setCursorPos(xpos+16, ypos+2)
|
|
monitor.write("100%")
|
|
end
|
|
|
|
function makeButton(label, xpos, ypos, width, height, color)
|
|
labelLength = string.len(label)
|
|
ycenter = ypos + height/2
|
|
xcenter = xpos + width/2
|
|
labelStart = (xcenter - labelLength/2)
|
|
|
|
border = window.create(monitor, xpos, ypos+1, width, height)
|
|
border.setBackgroundColor(color)
|
|
border.clear()
|
|
|
|
monitor.setCursorPos(labelStart, ypos)
|
|
monitor.setTextColor(colors.black)
|
|
monitor.write(label)
|
|
end
|
|
|
|
while true do
|
|
reactor = peripheral.wrap("BigReactors-Reactor_0")
|
|
monitor = peripheral.wrap("monitor_2")
|
|
reactorWrite(monitor, reactor)
|
|
monitor = peripheral.wrap("monitor_1")
|
|
reactorWrite(monitor, reactor)
|
|
os.sleep(.1)
|
|
end |