Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local reactor1 = peripheral.wrap("BigReactors-Reactor_4")
- local mon = peripheral.wrap("top")
- local x =peripheral.wrap("right")
- local alarm = true
- local storageMax = 85
- local controlleRod = reactor1.getControlRodLevel(0)
- local turbine = peripheral.wrap("BigReactors-Turbine_12")
- local xpos, ypos, monmessage = 1, 16, ""
- local stat="nothing" --storage or rod
- local active = "on"
- function affiche()
- mon.clear()
- -- Begin Reactor 1
- --mon.setCursorPos(1,1)
- --mon.setTextColor(colors.white)
- --mon.write("Reactor #: ")
- --mon.setTextColor(colors.lime)
- --mon.write("1")
- mon.setCursorPos(1,1)
- mon.setTextColor(colors.white)
- mon.write("Active: ")
- mon.setTextColor(colors.lime)
- mon.write(reactor1.getActive())
- mon.setCursorPos(1,2)
- mon.setTextColor(colors.white)
- mon.write("RF/T: ")
- mon.setTextColor(colors.lime)
- mon.write(math.floor(turbine.getEnergyProducedLastTick()))
- mon.setCursorPos(1,3)
- mon.setTextColor(colors.white)
- mon.write("RF Stored: ")
- mon.setTextColor(colors.lime)
- mon.write(math.floor(turbine.getEnergyStored()))
- mon.setCursorPos(1,4)
- mon.setTextColor(colors.white)
- mon.write("Casing Heat: ")
- mon.setTextColor(colors.lime)
- mon.write(math.floor(reactor1.getCasingTemperature()))
- mon.setCursorPos(1,5)
- mon.setTextColor(colors.white)
- mon.write("Fuel Heat: ")
- mon.setTextColor(colors.lime)
- mon.write(math.floor(reactor1.getFuelTemperature()))
- -- End Reactor 1
- --term.clear()
- term.setCursorPos(1,1)
- write("Write off to turn off ")
- term.setCursorPos(1,2)
- write("Write on to turn on ")
- term.setCursorPos(1,3)
- write("Write stop to stop the alert ")
- term.setCursorPos(1,5)
- if reactor1.getActive() then
- write(" ")
- term.setCursorPos(1,5)
- write("Reactor : ")
- term.setTextColor(colors.lime)
- write("on")
- term.setTextColor(colors.white)
- else
- write(" ")
- term.setCursorPos(1,5)
- write("Reactor : ")
- term.setTextColor(colors.lime)
- write("off")
- term.setTextColor(colors.white)
- end
- if turbine.getActive() then
- write(" ")
- term.setCursorPos(1,6)
- write("Turbine : ")
- term.setTextColor(colors.lime)
- write("on ")
- term.setTextColor(colors.white)
- else
- write(" ")
- term.setCursorPos(1,6)
- write("Turbine : ")
- term.setTextColor(colors.lime)
- write("off")
- term.setTextColor(colors.white)
- end
- term.setCursorPos(1,7)
- if alarm then
- write(" ")
- term.setCursorPos(1,7)
- write("Alarm ")
- term.setTextColor(colors.lime)
- write("on")
- term.setTextColor(colors.white)
- else
- write(" ")
- term.setCursorPos(1,7)
- write("alarm ")
- term.setTextColor(colors.lime)
- write("off")
- term.setTextColor(colors.white)
- end
- term.setCursorPos(1,9)
- write("Storage Max RF : ")
- term.setTextColor(colors.lime)
- write(storageMax)
- term.setTextColor(colors.white)
- write(", Rod Level : ")
- term.setTextColor(colors.lime)
- write(reactor1.getControlRodLevel(0))
- term.setTextColor(colors.white)
- --end affiche
- end
- function event1()
- while true do
- event, number, bool = os.pullEvent("key")
- if number == 33 then --off
- reactor1.setActive(false)
- alarm=false
- --term.setCursorPos(1,4)
- --term.setCursorPos(1,5)
- --write("off")
- --write("stoped")
- elseif number == 49 then
- reactor1.setActive(true) --on
- alarm=true
- --term.setCursorPos(1,4)
- --write("on")
- elseif number==31 then --stop
- alarm=false
- --term.setCursorPos(1,5)
- -- write("stoped")
- end
- end
- end
- function playAffiche()
- while true do
- affiche()
- sleep(0)
- end
- end
- function read()
- while true do
- local event, p1 = os.pullEvent()
- if (event == "char") and (xpos < 50) then
- monmessage = monmessage..p1
- term.setCursorPos(xpos,ypos)
- term.write(p1)
- xpos = xpos+1
- elseif event == "key" then
- if (p1 == 14) and (xpos > 1) then
- monmessage = string.sub( monmessage, 1, string.len( monmessage ) - 1 )
- xpos = xpos-1
- term.setCursorPos(xpos,ypos)
- term.write(" ")
- term.setCursorPos(xpos,ypos)
- elseif p1 == 28 then
- --monmessage = tostring( monmessage )
- --break
- envoiMsg()
- monmessage="" --peutetre faux je rajoute apres coup
- xpos, ypos = 1, 16
- term.setCursorPos(xpos,ypos)
- term.write(" ")
- term.setCursorPos(xpos,ypos)
- end
- end
- end
- end
- function envoiMsg()
- if monmessage == "rod" then
- stat = "rod"
- monmessage=""
- elseif monmessage == "storage" then
- stat = "storage"
- monmessage=""
- elseif monmessage == "turbine" then
- stat = "coil"
- monmessage=""
- elseif monmessage =="++" then
- if stat=="rod" then
- controlleRod=controlleRod+10
- reactor1.setAllControlRodLevels(controlleRod)
- elseif stat=="storage" then
- storageMax=storageMax+10
- end
- stat = "nothing"
- monmessage=""
- elseif monmessage =="--" then
- if stat=="rod" then
- controlleRod=controlleRod-10
- reactor1.setAllControlRodLevels(controlleRod)
- elseif stat=="storage" then
- storageMax=storageMax-10
- end
- stat = "nothing"
- monmessage=""
- elseif monmessage == "off" then
- if stat == "coil" then
- turbine.setConnected(false)
- elseif stat=="nothing" then
- reactor1.setActive(false)
- alarm=false
- active = "off"
- end
- elseif monmessage == "on" then
- if stat == "coil" then
- turbine.setConnected(true)
- elseif stat=="nothing" then
- reactor1.setActive(true) --on
- active = "on"
- alarm=true
- end
- elseif monmessage == "stop" then
- alarm=false
- else
- stat = "nothing"
- monmessage=""
- end
- monmessage=""
- end
- function readController()
- while true do
- if stat == "nothing" then
- term.setCursorPos(1,11)
- term.setTextColor(colors.red)
- write("Write rod to modify the production or storage to modify max storage of RF or turbine to turn on/off")
- term.setTextColor(colors.white)
- elseif stat == "rod" then
- term.setCursorPos(1,11)
- write(" ")
- term.setCursorPos(1,11)
- term.setTextColor(colors.red)
- write("Write ++ or -- (+10 or -10), it is : "..reactor1.getControlRodLevel(0))
- term.setTextColor(colors.white)
- term.setCursorPos(1,12)
- write(" ")
- term.setCursorPos(1,13)
- write(" ")
- elseif stat == "storage" then
- term.setCursorPos(1,11)
- write(" ")
- term.setCursorPos(1,11)
- term.setTextColor(colors.red)
- write("Write ++ or -- (+10 or -10), it is: "..storageMax)
- term.setTextColor(colors.white)
- term.setCursorPos(1,12)
- write(" ")
- term.setCursorPos(1,13)
- write(" ")
- elseif stat == "coil" then
- term.setCursorPos(1,11)
- write(" ")
- term.setCursorPos(1,11)
- term.setTextColor(colors.red)
- write("Write on or off to turn on or off the turbine ")
- term.setTextColor(colors.white)
- term.setCursorPos(1,12)
- write(" ")
- term.setCursorPos(1,13)
- write(" ")
- end
- sleep(1)
- end
- end
- function controller()
- while true do
- if reactor1.getActive() and reactor1.getEnergyStored()/100000 >=storageMax then
- reactor1.setActive(false)
- redstone.setOutput("left",true)
- elseif not (reactor1.getActive()) and active == "on" and reactor1.getEnergyStored()/100000 <= storageMax-20 then
- reactor1.setActive(true)
- redstone.setOutput("left",false)
- end
- sleep(1)
- end
- end
- function play()
- while true do
- while reactor1.getFuelAmount() <3000 and alarm==true and reactor1.getActive() do
- redstone.setOutput("left",true)
- x.setPitch(23)
- x.triggerNote()
- sleep(1)
- x.setPitch(24)
- x.triggerNote()
- redstone.setOutput("left",false)
- sleep(1)
- end
- redstone.setOutput("left",false)
- sleep(1)
- end
- end
- reactor1.setActive(true)
- term.clear()
- parallel.waitForAny(play,playAffiche,readController,controller,read)
- function afficheCommand()
- while true do
- local reactor = peripheral.wrap("BigReactors-Reactor_4")
- print("getConnected: ", reactor.getConnected())
- print("getActive: ", reactor.getActive())
- print("getNumberOfControlRods: ", reactor.getNumberOfControlRods())
- print("getEnergyStored: ", reactor.getEnergyStored())
- print("getFuelTemperature: ", reactor.getFuelTemperature())
- print("getCasingTemperature: ", reactor.getCasingTemperature())
- print("getFuelAmount: ", reactor.getFuelAmount())
- print("getWasteAmount: ", reactor.getWasteAmount())
- print("getFuelAmountMax: ", reactor.getFuelAmountMax())
- print("getControlRodName: ", reactor.getControlRodName(0))
- print("getControlRodLevel: ", reactor.getControlRodLevel(0))
- print("getEnergyProducedLastTick: ", reactor.getEnergyProducedLastTick())
- print("getCoolantAmount: ", reactor.getCoolantAmount())
- print("getCoolantType: ", reactor.getCoolantType())
- print("getHotFluidAmount: ", reactor.getHotFluidAmount())
- print("getHotFluidType: ", reactor.getHotFluidType())
- print("getFuelReactivity: ", reactor.getFuelReactivity())
- print("getFuelConsumedLastTick: ", reactor.getFuelConsumedLastTick())
- print("isActivelyCooled: ", reactor.isActivelyCooled())
- -- reactor.setActive(boolean)
- -- reactor.setAllControlRodLevels(level 0-100)
- -- reactor.setControlRodLevel(index, level 0-100)
- -- doEjectWaste()
- sleep(5)
- end
- end
Add Comment
Please, Sign In to add comment