Advertisement
Imgoodisher

Computercraft reactor controller

May 14th, 2012
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.84 KB | None | 0 0
  1. TimeMultiplier = 60
  2. CycleTime = 45
  3. CooldownTime = 1
  4.  
  5. function turnOn() rs.setOutput("back", true) end
  6. function turnOff() rs.setOutput("back", false) end
  7. while true do
  8.  
  9. print("How many cycles should run?")
  10. write("Cycles> ")
  11. numCycles = read()
  12.  
  13. for i=1,numCycles do
  14.  term.clear()
  15.  term.setCursorPos(1, 1)
  16.  print("+-----------------------------------------------+")
  17.  print("|               Refuel Reactor                  |")
  18.  print("|         Press ENTER when refueled             |")
  19.  print("+-----------------------------------------------+")
  20.  --[[while true do
  21.   event, arg = os.pullEvent()
  22.   if event == "key" and arg == 28 then break end
  23.  end--]]
  24.  term.clear()
  25.  term.setCursorPos(1, 1)
  26.  print("+-----------------------------------------------+")
  27.  print("|             Reactor is running                |")
  28.  print("|               Time Left:                      |")
  29.  print("+-----------------------------------------------+")
  30.  turnOn()
  31.  timeleft = CycleTime
  32.  for i=1, CycleTime do
  33.   if timeleft < 10 then CT = tostring(timeleft).." " else CT = tostring(timeleft) end
  34.   term.setCursorPos(1, 3)
  35.   term.clearLine()
  36.   print("|               Time Left: "..CT.."                   |")
  37.   sleep(TimeMultiplier)
  38.   timeleft = timeleft-1
  39.  end
  40.  turnOff()
  41.  term.clear()
  42.  term.setCursorPos(1, 1)
  43.  print("+-----------------------------------------------+")
  44.  print("|            Reactor is cooling down            |")
  45.  print("|               Time Left:                      |")
  46.  print("+-----------------------------------------------+")
  47.  timeleft = CooldownTime
  48.  if CooldownTime ~= 0 then
  49.   for i=1, CooldownTime do
  50.    if timeleft <10 then CdT = tostring(timeleft).." " else CdT = tostring(timeleft) end
  51.    term.setCursorPos(28, 3)
  52.    print(CdT.."                   |")
  53.    sleep(TimeMultiplier)
  54.    timeleft = timeleft-1
  55.   end
  56.  end
  57. end
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement