Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- num = 1
- screennum = 1
- local MaxOutput = 120
- screen = peripheral.wrap("monitor_"..screennum)
- speaker = peripheral.wrap("top")
- rednet.open("front")
- 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))
- 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)
- 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)
- 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)
- speaker.playSound("minecraft:ui.button.click")
- 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)
- speaker.playSound("minecraft:ui.button.click")
- 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