kd8lvt

[UNFINISHED] Bigreactors Control Program

Jun 14th, 2015
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.93 KB | None | 0 0
  1. --Peripherals
  2. r1 = peripheral.wrap("BigReactors-Reactor_1")
  3. r2 = peripheral.wrap("BigReactors-Reactor_2")
  4. r3 = peripheral.wrap("BigReactors-Reactor_3")
  5. r4 = peripheral.wrap("BigReactors-Reactor_4")
  6. --Functions
  7. function getInput()
  8.   shell.run("clear")
  9.   print("> ")
  10.   input = io.read()
  11.   parseInput(input)
  12. end
  13. ------
  14. function parseInput(input)
  15.   shell.run("clear")
  16.   if input == "override" then
  17.     print("What reactor would you like to toggle manual override for? [1-4]: ")
  18.     reactnum = io.read()
  19.     if reactnum == 1 then
  20.       man1 = true
  21.     elseif reactnum == 2 then
  22.       man2 = true
  23.     elseif reactnum == 3 then
  24.       man3 = true
  25.     elseif reactnum == 4 then
  26.       man4 = true
  27.     end
  28.   elseif input == "auto" then
  29.     print("Which reactor would you like to turn back to auto? [1-4 / all]: ")
  30.     reactnum = io.read()
  31.     if reactnum == all then
  32.       man1 = false
  33.       man2 = false
  34.       man3 = false
  35.       man4 = false
  36.     elseif reactnum == 1 then
  37.       man1 = false
  38.     elseif reactnum == 2 then
  39.       man2 = false
  40.     elseif reactnum == 3 then
  41.       man3 = false
  42.     elseif reactnum == 4 then
  43.       man4 = false
  44.     end
  45.   elseif input == "on" then
  46.     print("Which reactor would you like to manually turn on? [1-4]: ")
  47.     reactnum = io.read()
  48.     if reactnum == 1 then
  49.       if man1 then
  50.         if r1.getActive() then
  51.           print("Reactor 1 is already on!")
  52.         else
  53.           print("Activating Reactor 1!")
  54.           r1.setActive(true)
  55.           if r1.getActive() then
  56.             print("Reactor 1 is ON!")
  57.           end
  58.        end
  59.      else
  60.        print("Reactor 1 is on automatic mode. Please turn it to manual before preforming this command.")
  61.      end
  62.    elseif reactnum == 2 then
  63.      if man2 then
  64.        if r2.getActive() then
  65.          print("Reactor 2 is already on!")
  66.        else
  67.          print("Activating Reactor 2!")
  68.          r2.setActive(true)
  69.          if r2.getActive() then
  70.            print("Reactor 2 is ON!")
  71.          end
  72.        end
  73.      else
  74.        print("Reactor 2 is on automatic mode. Please turn it to manual before preforming this command.")
  75.      end
  76.    elseif reactnum == 3 then
  77.      if man3 then
  78.        if r3.getActive() then
  79.          print("Reactor 3 is already on!")
  80.        else
  81.          print("Activating Reactor 3!")
  82.          r3.setActive(true)
  83.          if r3.getActive() then
  84.            print("Reactor 3 is ON!")
  85.          end
  86.        end
  87.      else
  88.        print("Reactor 3 is on automatic mode. Please turn it to manual before preforming this command.")
  89.      end
  90.    elseif reactnum == 4 then
  91.      if man4 then
  92.        if r4.getActive() then
  93.          print("Reactor 4 is already on!")
  94.        else
  95.          print("Activating Reactor 4!")
  96.          r4.setActive(true)
  97.          if r4.getActive() then
  98.            print("Reactor 4 is ON!")
  99.          end
  100.        end
  101.      else
  102.        print("Reactor 4 is on automatic mode. Please turn it to manual before preforming this command.")
  103.      end
  104.    end
  105.   else if input == "off" then
  106.     print("Which reactor would you like to manually turn off? [1-4]: ")
  107.     reactnum = io.read()
  108.     if reactnum == 1 then
  109.       if man1 then
  110.         if r1.getActive() == false then
  111.           print("Reactor 1 is already off!")
  112.         else
  113.           print("Turning off Reactor 1!")
  114.           r1.setActive(false)
  115.           if r1.getActive() == false then
  116.             print("Reactor 1 is OFF!")
  117.           end
  118.        end
  119.      else
  120.        print("Reactor 1 is on automatic mode. Please turn it to manual before preforming this command.")
  121.      end
  122.    elseif reactnum == 2 then
  123.      if man2 then
  124.        if r2.getActive() == false then
  125.          print("Reactor 2 is already off!")
  126.        else
  127.          print("Turning off Reactor 2!")
  128.          r2.setActive(false)
  129.          if r2.getActive() == false then
  130.            print("Reactor 2 is OFF!")
  131.          end
  132.        end
  133.      else
  134.        print("Reactor 2 is on automatic mode. Please turn it to manual before preforming this command.")
  135.      end
  136.    elseif reactnum == 3 then
  137.      if man3 then
  138.        if r3.getActive() == false then
  139.          print("Reactor 3 is already off!")
  140.        else
  141.          print("Turning off Reactor 3!")
  142.          r3.setActive(false)
  143.          if r3.getActive() == false then
  144.            print("Reactor 3 is OFF!")
  145.          end
  146.        end
  147.      else
  148.        print("Reactor 3 is on automatic mode. Please turn it to manual before preforming this command.")
  149.      end
  150.    elseif reactnum == 4 then
  151.      if man4 then
  152.        if r4.getActive() == false then
  153.          print("Reactor 4 is already off!")
  154.        else
  155.          print("Turning off Reactor 4!")
  156.          r4.setActive(false)
  157.          if r4.getActive() == false then
  158.            print("Reactor 4 is ON!")
  159.          end
  160.        end
  161.      else
  162.        print("Reactor 4 is on automatic mode. Please turn it to manual before preforming this command.")
  163.      end
  164.   end
  165. end
  166. end
  167. end
  168.  
  169. while true do
  170.     getInput()
  171. end
Advertisement
Add Comment
Please, Sign In to add comment