Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Reactor Control software v0.1
- local reactor
- local turbine
- local monitor
- local mode
- local max=1500
- local min=900
- function initHardware()
- local table=peripheral.getNames()
- for i,p in pairs(table) do
- local type=peripheral.getType(p)
- if type=="BigReactors-Reactor" then
- reactor=peripheral.wrap(p)
- elseif type=="BigReactors-Turbine" then
- turbine=peripheral.wrap(p)
- elseif type=="monitor" then
- monitor=peripheral.wrap(p)
- end
- end
- if reactor==nil then
- print("No reactor found")
- exit()
- elseif turbine==nil then
- mode="Active"
- else
- mode="Passive"
- end
- print(mode.." cooling mode")
- end
- function checkStatus()
- if mode=="Active" then
- if reactor.getActive() and turbine.getInductorEnabled() then
- return "Active"
- elseif reactor.getActive() then
- return "Spooling up turbine"
- elseif turbine.getInductorEnabled() then
- return "Spooling down turbine"
- else
- return "Inactive"
- end
- elseif mode=="Passive" then
- if reactor.getActive() then
- return "Active"
- else
- return "Inactive"
- end
- end
- end
- function start()
- term.clear()
- term.setCursorPos(1,1)
- print("Initializing reactor")
- reactor.setActive(true)
- if not turbine.getActive() then
- turbine.setActive(true)
- end
- print("Spooling up turbine")
- local x,y=term.getCursorPos()
- while turbine.getRotorSpeed()<min do
- term.setCursorPos(x,y)
- term.clearLine()
- print(turbine.getRotorSpeed().."rpm")
- sleep(1)
- end
- term.setCursorPos(x,y)
- term.clearLine()
- print("Engaging inductor")
- turbine.setInductorEngaged(true)
- print("Status: Active")
- end
- function stop()
- term.clear()
- term.setCursorPos(1,1)
- print("Shutting down reactor")
- reactor.setActive(false)
- print("Spooling down turbine")
- local x,y=term.getCursorPos()
- while turbine.getRotorSpeed()>max do
- term.setCursorPos(x,y)
- term.clearLine()
- print(turbine.getRotorSpeed().." rpm")
- sleep(1)
- end
- term.setCursorPos(x,y)
- term.clearLine()
- print("Disengaging turbine")
- turbine.setInductorEngaged(false)
- print("Status: Shutdown")
- end
- term.clear()
- term.setCursorPos(1,1)
- initHardware()
- repeat
- write("Input command: ")
- line=read()
- if line=="start" then
- start()
- elseif line=="stop" then
- stop()
- elseif line~="exit" then
- print("Invalid command")
- end
- until line=="exit"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement