Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------
- ------------------For Minecraft-------------------
- ---For 2 IC2 reactor on each side of a computer---
- ------------For advanced computers only-----------
- --------------------------------------------------
- softwareVersion = "2.2"
- y = 1
- rednet.open("back")
- --------------------------------------------------
- function time()
- local time = os.time()
- ttc(colors.gray)
- timeF = textutils.formatTime(time,true)
- if time < 10 then
- term.setCursorPos(1,y)
- write("[0"..timeF.."]")
- T = "[0"..timeF.."]"
- else
- term.setCursorPos(1,y)
- write("["..timeF.."]")
- T = "["..timeF.."]"
- end
- end
- --------------------------------------------------
- function ver()
- term.setCursorPos(1,1)
- ttc(colors.yellow)
- write("ReactorControl V"..softwareVersion)
- end
- --------------------------------------------------
- function line()
- ver()
- if y <=13 then
- y=y+1
- else
- term.scroll(1)
- end
- term.setCursorPos(8,y)
- end
- --------------------------------------------------
- function ttc(x)
- term.setTextColor(x)
- end
- --------------------------------------------------
- function prompt()
- ttc(colors.white)
- write(":")
- ttc(colors.green)
- write("Admin ")
- ttc(colors.yellow)
- write("$> ")
- ttc(colors.white)
- command = read()
- end
- --------------------------------------------------
- function helpCommand()
- ttc(colors.yellow)
- write(" --------------")
- line()
- ttc(colors.lightBlue)
- write(" help ")
- ttc(colors.white)
- write("= ")
- ttc(colors.lime)
- write("List all commands")
- line()
- ttc(colors.lightBlue)
- write(" core ")
- ttc(colors.white)
- write("[")
- ttc(colors.lightGray)
- write("side")
- ttc(colors.white)
- write("] ")
- write("[")
- ttc(colors.lightGray)
- write("on")
- ttc(colors.white)
- write("/")
- ttc(colors.lightGray)
- write("off")
- ttc(colors.white)
- write("] ")
- ttc(colors.white)
- write("= ")
- ttc(colors.lime)
- write("Core on")
- ttc(colors.white)
- write("/")
- ttc(colors.lime)
- write("off")
- line()
- ttc(colors.lightBlue)
- write(" energy amount ")
- ttc(colors.white)
- write("= ")
- ttc(colors.lime)
- write("Check energy amount")
- line()
- ttc(colors.lightBlue)
- write(" clear ")
- ttc(colors.white)
- write("= ")
- ttc(colors.lime)
- write("Clear the terminal")
- line()
- ttc(colors.lightBlue)
- write(" stop ")
- ttc(colors.white)
- write("= ")
- ttc(colors.lime)
- write("Stop the reactor")
- line()
- ttc(colors.lightBlue)
- write(" run ")
- ttc(colors.white)
- write("= ")
- ttc(colors.lime)
- write("Run the reactor")
- line()
- ttc(colors.yellow)
- write(" --------------")
- line()
- end
- --------------------------------------------------
- function core(side,status,col)
- ttc(colors.lightGray)
- write(" Waiting")
- sleep(0.5)
- write(".")
- sleep(0.5)
- write(".")
- sleep(0.5)
- write(".")
- line()
- ttc(colors.yellow)
- write(" >>> ")
- ttc(colors.lightBlue)
- write("Core ")
- ttc(colors.lime)
- write(side)
- ttc(colors.lightBlue)
- write(" is ")
- ttc(col)
- write(status)
- line()
- if side == "Left" and status == "ON" then
- rs.setOutput("left",true)
- elseif side == "Left" and status == "OFF" then
- rs.setOutput("left",false)
- elseif side == "Right" and status == "ON" then
- rs.setOutput("right",true)
- elseif side == "Right" and status == "OFF" then
- rs.setOutput("right",false)
- end
- end
- --------------------------------------------------
- function termClear()
- term.clear()
- y=1
- line()
- end
- --------------------------------------------------
- function stop()
- ttc(colors.lightGray)
- write(" Stopping")
- sleep(0.5)
- write(".")
- sleep(0.5)
- write(".")
- sleep(0.5)
- write(".")
- line()
- ttc(colors.yellow)
- write(" >>> ")
- ttc(colors.lightBlue)
- write("Reactor ")
- ttc(colors.red)
- write("STOPPED")
- rs.setOutput("left",false)
- rs.setOutput("right",false)
- line()
- end
- --------------------------------------------------
- function run()
- ttc(colors.lightGray)
- write(" Running")
- sleep(0.5)
- write(".")
- sleep(0.5)
- write(".")
- sleep(0.5)
- write(".")
- sleep(0.5)
- line()
- ttc(colors.yellow)
- write(" >>> ")
- ttc(colors.lightBlue)
- write("Reactor is ")
- ttc(colors.green)
- write("RUNNING")
- line()
- rs.setOutput("left",true)
- rs.setOutput("right",true)
- end
- --------------------------------------------------
- function logsW()
- h = fs.open("logLine","r")
- l = h.readLine(1)
- h.close()
- logFile = fs.open("logs","a")
- logFile.writeLine(T.." : "..command,l)
- logFile.close()
- l = l+1
- h = fs.open("logLine","w")
- h.write(l)
- h.close()
- end
- --------------------------------------------------
- function energyAmount()
- ttc(colors.lightGray)
- write(" Checking...")
- line()
- id, data = rednet.receive(1)
- e = string.reverse(data)
- if data < 1000 then
- C = data
- elseif data >= 1000 and data <1000000 then
- a = string.sub(e, 1,3)
- A = a.." "
- b = string.sub(e, 4,6)
- C = A..b
- eF = string.reverse(C)
- elseif data >= 1000000 then
- a = string.sub(e, 1,3)
- A = a.." "
- b = string.sub(e, 4,6)
- B = b.." "
- c = string.sub(e,7,9)
- C = A..B..c
- eF = string.reverse(C)
- end
- ttc(colors.yellow)
- write(" >>> ")
- ttc(colors.lime)
- write(eF.." ")
- ttc(colors.lightBlue)
- write("EU")
- line()
- end
- --------------------------------------------------
- term.clear()
- line()
- --Main loop
- while true do
- prompt()
- time()
- line()
- logsW()
- if command == "help" then
- helpCommand()
- elseif command == "core left on" then
- core("Left","ON",colors.green)
- elseif command == "core left off" then
- core("Left","OFF",colors.red)
- elseif command == "core right on" then
- core("Right","ON",colors.green)
- elseif command == "core right off" then
- core("Right","OFF",colors.red)
- elseif command == "clear" then
- termClear()
- elseif command == "energy amount" then
- energyAmount()
- elseif command == "stop" then
- stop()
- elseif command == "run" then
- run()
- elseif command == "/logs" then
- shell.openTab("logRead")
- shell.switchTab(2)
- else
- ttc(colors.red)
- write(" Unknown command try help")
- line()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement