Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- num = 1
- screennum1 = 1
- screennum2 = 2
- local MaxOutput = 120
- screen = peripheral.wrap("monitor_"..screennum1)
- screen2 = peripheral.wrap("monitor_"..screennum2)
- rednet.open("right")
- local Temp = 0
- Output = 0
- Power = 0
- function clear()
- screen.setBackgroundColor(32768)
- screen.clear()
- screen.setCursorPos(1,1)
- end
- function drawLine(x, y, length, size, color_bar)
- for yPos = y, y+length-1 do
- screen.setBackgroundColor(color_bar)
- screen.setCursorPos(x, yPos)
- screen.write(string.rep(" ", size))
- screen2.setBackgroundColor(color_bar)
- screen2.setCursorPos(x, yPos)
- screen2.write(string.rep(" ", size))
- end
- end
- function drawProg(x, y, length, size, minVal, maxVal, color_bar, color_bg)
- drawLine(x, y, length, size, color_bg)
- local barSize = math.floor((minVal/maxVal)*length)
- drawLine(x, y, barSize, size, color_bar)
- end
- function OutputText()
- screen.setBackgroundColor(32768)
- screen.setCursorPos(2,6)
- screen.write(math.floor(Output * 100) / 100)
- screen2.setBackgroundColor(32768)
- screen2.setCursorPos(2,6)
- screen2.write(math.floor(Output * 100) / 100)
- end
- function powerOn()
- for i = 0, MaxOutput do
- drawProg(0,7, 20, 10, i, MaxOutput, 8192, 32768)
- Output = i
- OutputText()
- sleep(0.001)
- end
- end
- function powerOff()
- for i = 0, MaxOutput do
- drawProg(0,7, 20, 10, MaxOutput-i, MaxOutput, 16384, 32768)
- Output = MaxOutput-i
- OutputText()
- sleep(0.001)
- end
- clear()
- end
- function updateStats(Status)
- screen.setCursorPos(2,1)
- screen.write(Status)
- screen.setCursorPos(2,3)
- screen.write("TEMP")
- screen.setCursorPos(2,4)
- screen.write(Temp)
- screen2.setCursorPos(2,1)
- screen2.write(Status)
- screen2.setCursorPos(2,3)
- screen2.write("TEMP")
- screen2.setCursorPos(2,4)
- screen2.write(Temp)
- end
- function updateScreen(Power)
- if Power == "ON" then
- clear()
- updateStats("ON")
- powerOn()
- elseif Power == "OFF" then
- clear()
- updateStats("OFF")
- powerOff()
- end
- end
- clear()
- while true do
- local id, message = rednet.receive()
- if message == "poweronreactor_"..num and Power == 0 then
- rednet.broadcast("Reactor"..num.." is Starting")
- redstone.setOutput("bottom", true)
- redstone.setOutput("top", true)
- updateScreen("ON")
- Power = 1
- rednet.broadcast("Reactor"..num.." has Started")
- elseif message == "poweroffreactor_"..num and Power == 1 then
- rednet.broadcast("Reactor"..num.." is Shutting Down")
- redstone.setOutput("bottom", false)
- redstone.setOutput("top", false)
- updateScreen("OFF")
- Power = 0
- rednet.broadcast("Reactor"..num.." is Offline")
- end
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement