HANDZ

Nuclear control

Jul 12th, 2018
138
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2. *****************************
  3. ()     Nuclear control     ()
  4. *****************************
  5. Made by: HANDZ
  6.  
  7. connect all wires through bundled cable, connected to the back of a computer !!
  8. overheat - yellow wire
  9. active - black wire
  10. full storage - pink wire
  11. user interaction - blue wire
  12.  
  13. output to reactor - lime wire
  14. place alarm on top of a computer --> it will turn on if the reactor is overheating
  15. --]]
  16.  
  17. --code dont touch :D
  18. x,y = term.getSize()
  19. overHeat = false
  20. active = false
  21. fullStorage = false
  22. userInteraction = false
  23. log = ""
  24. fl = true
  25.  
  26. function reactor(st)
  27.  setO = rs.setBundledOutput
  28.  
  29.  if st == "activate" then
  30.   setO("back", 0)
  31.  else
  32.   setO("back", colors.lime)
  33.  end
  34. end
  35.  
  36. function alarm(st)
  37.  sAO = rs.setOutput
  38.  if st == "activate" then
  39.   sAO("top", true)
  40.  else
  41.   sAO("top", false)
  42.  end
  43. end
  44.  
  45. function drawLogo()
  46.  x,y = term.getSize()
  47.  term.clear()
  48.  term.setCursorPos(1,1)
  49.  drawAcros(1,"*")
  50.  drawCentred(2,"Nuclear control","()")
  51.  drawAcros(3,"*")
  52. end
  53.  
  54. function readInputs()
  55.  rsTest = rs.testBundledInput
  56.  overHeat = rsTest("back", colors.yellow)
  57.  active = not(rsTest("back", colors.black))
  58.  fullStorage = rsTest("back", colors.pink)
  59.  userInteraction = rsTest("back", colors.blue)
  60. end
  61.  
  62. function updateReactorStatus()
  63.  if not(overHeat or userInteraction or fullStorage) then
  64.   reactor("activate")
  65.  else
  66.   reactor("deactivate")
  67.  end
  68.  
  69.  if overHeat then
  70.   alarm("activate")
  71.  else
  72.   alarm("deactivate")
  73.  end
  74.  
  75.  if overHeat and not(userInteraction) then
  76.   if active then
  77.    print("Reactor status: OVERHEATING")
  78.    print()
  79.    print("!!! Shutting Down !!!")
  80.    print()
  81.   else
  82.    print("Reactor status: Cooling down")
  83.   end
  84.  elseif active then
  85.   print("Reactor status: ONLINE")
  86.  else
  87.   print("Reactor status: OFFLINE")
  88.  end
  89.  
  90.  if userInteraction then
  91.   print("/-/ user interaction /-/")
  92.  end
  93.  
  94.  if fullStorage then
  95.   print("Storage status: FULL")
  96.   if active and not(overHeat or userInteraction) then
  97.    print()
  98.    print("Shutting down")
  99.    print()
  100.   end
  101.  else
  102.   print("Storage status: OK")
  103.  end
  104.  
  105.  log = "Shutted down because of"
  106.  fl = true
  107.  if overHeat then
  108.   log = log.." overheating"
  109.   fl = false
  110.  end
  111.  
  112.  if userInteraction then
  113.   if not(fl) then
  114.    log = log.." and"
  115.   end
  116.   log = log.." user interaction"
  117.   fl = false
  118.  end
  119.  
  120.  if fullStorage then
  121.   if not(fl) then
  122.    log = log.." and"
  123.   end
  124.   log = log.." full storage"
  125.   fl = false
  126.  end
  127.  
  128.  if not(active) then
  129.   print()
  130.   print(log)
  131.  end
  132. end
  133.  
  134. function drawCentred(line,text,char)
  135.  term.setCursorPos(1,line)
  136.  term.write(char)
  137.  
  138.  local a = (x - string.len(text)) / 2
  139.  term.setCursorPos(a+1, line)
  140.  term.write(text)
  141.  
  142.  local b = x - string.len(char)
  143.  term.setCursorPos(b+1,line)
  144.  term.write(char)
  145. end
  146.  
  147. function drawAcros(line, char)
  148.  term.setCursorPos(1, line)
  149.  for i=0,x do
  150.   term.write(char)
  151.  end
  152. end
  153.  
  154. while true do
  155.  drawLogo()
  156.  readInputs()
  157.  updateReactorStatus()
  158.  drawCentred(y,"Made by: HANDZ","+++")
  159.  sleep(0.01)
  160. end
RAW Paste Data