Drunkmonkey

Computer Craft IC2 Reactor Control Version 0.2

Jan 30th, 2021 (edited)
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.66 KB | None | 0 0
  1. --Version 0.3--
  2. --made by Kyle Hendry(Void)--
  3. --this program is to act as a safeguard to prevent meltdowns and export reactor info to monitor displays over red net--
  4.  
  5. function Clear()
  6.     term.setBackgroundColor(colours.black)
  7.     term.clear()
  8.     term.setCursorPos(1,1)
  9. end
  10.  
  11. print("RednetID: " .. os.getComputerID())
  12.  
  13. print("What side is the modem on?")
  14. side = read()
  15. peripheral.wrap(side)
  16. rednet.open(side)
  17.  
  18. function SendInfo(side)
  19.     while true do
  20.         temp = getHeat()
  21.         EU = getEUOutput()
  22.  
  23.         print("Reactor Temp: " .. temp)
  24.         print("")
  25.         print("Reactor Output: " .. EU .. "EU/t")
  26.         sleep(2)
  27.     end
  28. end
  29.  
  30. Clear()
  31. print("What side is the reactor on?")
  32. reactor = read()
  33. peripheral.wrap("reactor")
  34.  
  35. Clear()
  36.  
  37. print("Enter Password To Begin Reactor Start Sequence.")
  38. start = read()
  39.  
  40. maxTemp = getMaxHeat()
  41. overheat = maxTemp * .80
  42. maxAttempt = 0
  43. temp = getHeat()
  44.  
  45.  
  46. function Shutdown(reactor)
  47.     redstone.setOutput(reactor, false)
  48.     rednet.close(side)
  49.     os.reboot()
  50. end
  51.  
  52. function Startup(reactor, temp, overheat)
  53.     Clear()
  54.     print("Password Accepted Begining Startup...")
  55.     sleep(5)
  56.     Clear()
  57.     redstone.setOutput(reactor, true)
  58.  
  59.     if temp ~= overheat then
  60.         Clear()
  61.         print("System is Active and Normal")
  62.         SendInfo()
  63.    
  64.  
  65.     else
  66.         Shutdown()
  67.     end
  68.    
  69. end
  70.  
  71. if start == "1776" then
  72.     maxAttempt = 0
  73.     Startup()
  74.  
  75.     elseif maxAttempt < 3 then
  76.     print("Incorrect password please try again")
  77.     Clear()
  78.     maxAttempt= maxAttempt + 1
  79.  
  80.     else
  81.     print("To many attempts made please wait 1 minute")
  82.     sleep(60)
  83.     os.reboot()
  84. end
Add Comment
Please, Sign In to add comment