Future_Crafter47

Command Room Terminal

Nov 29th, 2020 (edited)
669
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. speaker = peripheral.find("speaker")
  2. modem = peripheral.find("modem")
  3. criterror = false
  4. playwarning = false
  5.  
  6. term.clear()
  7. term.setCursorPos(1,1)
  8. modem.open(1293)
  9. modem.open(1294)
  10.  
  11. speaker.synthesize("Booting Up...")
  12. print("Future O.S.")
  13. print("Booting Up...")
  14. --term.setCursorPos(30,10)
  15. textutils.slowPrint("#############",6)
  16. speaker.synthesize("Base Online...")
  17. term.clear()
  18. local function createwindows()
  19.  
  20.     warningwindow = window.create(term.current(),10,5,35,12,false)
  21.     warningwindow.setBackgroundColor(colors.red)
  22.     warningwindow.clear()
  23.     warningwindow.setCursorPos(13,6)
  24.     warningwindow.setTextColor(colors.black)
  25.    
  26.     reactorwindow = window.create(term.current(),1,1,30,10,true)
  27.     basewindow = window.create(term.current(),31,1,34,15,true)
  28.    
  29.     basewindow.setBackgroundColor(colors.black)
  30.     reactorwindow.setBackgroundColor(colors.black)
  31.    
  32.    
  33.    
  34.     basewindow.clear()
  35.     reactorwindow.clear()
  36.    
  37.     basewindow.setCursorPos(1,1)
  38.     basewindow.setTextColor(colors.white)
  39.    
  40.    
  41.    
  42.     reactorwindow.setCursorPos(1,1)
  43.     reactorwindow.setTextColor(colors.white)
  44.     reactorwindow.write("Reactor Status: Unknown")
  45.    
  46. end
  47. local function displaybasestatus(texttopost)
  48.    
  49.     local xl,yl = basewindow.getCursorPos()
  50.     basewindow.setCursorPos(1,yl + 1)
  51.     basewindow.write(texttopost)
  52.     if(xl + 1 < 15) then
  53.         basewindow.clear()
  54.         basewindow.setCursorPos(1,1)
  55.     end
  56. end
  57.  
  58. local function displayreactor()
  59.     while true do
  60.         reactorstatus = {}
  61.         modem.transmit(1293, 1294, "status")
  62.         local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  63.        
  64.         for token in string.gmatch(message, "[^%s]+") do
  65.             table.insert(reactorstatus, token)
  66.         end
  67.        
  68.         if(oldreactorstatus == nil) then
  69.             displaybasestatus("Reactor Status set to: " .. reactorstatus[3])
  70.         elseif(reactorstatus[3] ~= oldreactorstatus) then
  71.             displaybasestatus("Reactor Status set to: " .. reactorstatus[3])
  72.         end
  73.         reactorwindow.clear()
  74.         reactorwindow.setCursorPos(1,1)
  75.         reactorwindow.setTextColor(colors.white)
  76.         reactorwindow.write("Reactor Status: " .. reactorstatus[3])
  77.        
  78.         reactorwindow.setCursorPos(1,2)
  79.        
  80.         if(4000 < tonumber(reactorstatus[1]) and tonumber(reactorstatus[1])  < 6000) then
  81.             reactorwindow.setTextColor(colors.orange)
  82.         elseif(6000 < tonumber(reactorstatus[1]) and tonumber(reactorstatus[1]) < 9200) then
  83.             reactorwindow.setTextColor(colors.red)
  84.             playwarning = false
  85.         elseif(9000 <= tonumber(reactorstatus[1])) then
  86.             reactorwindow.setTextColor(colors.red)
  87.             displaybasestatus("Evacuate the Area Immediantly!!!")
  88.             playwarning = true
  89.         end
  90.        
  91.         reactorwindow.write("Reactor Heat: " .. reactorstatus[1])
  92.         reactorwindow.setCursorPos(1,3)
  93.        
  94.         reactorwindow.setTextColor(colors.white)
  95.         reactorwindow.write("Reactor EU Output: " .. reactorstatus[2])
  96.         oldreactorstatus = reactorstatus[3]
  97.  
  98.         sleep(0)
  99.        
  100.     end
  101. end
  102.  
  103. local function dummyfunction()
  104.  
  105.     while true do
  106.         while(playwarning == true) do
  107.             speaker.synthesize("Explosion Imminent, Evacuate the Area Immediantly!")
  108.             os.sleep(3)
  109.         end
  110.         sleep(0)
  111.     end
  112. end
  113.  
  114. createwindows()
  115. basewindow.write("Started up Systems...")
  116.  
  117. while true do
  118.     parallel.waitForAll(displayreactor, dummyfunction)
  119.     sleep(0)
  120. end
  121.  
RAW Paste Data