Advertisement
Tommo5261

Monitor

Aug 23rd, 2019
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.59 KB | None | 0 0
  1. monitor = peripheral.wrap("left")
  2. oldTerm = term.redirect(monitor)
  3. rednet.open("front")
  4.  
  5. function clearMonitor(s)
  6.     s = s or 0.8
  7.     monitor.clear()
  8.     monitor.setCursorPos(1,1)
  9.     monitor.setTextScale(s)
  10. end
  11.  
  12. function protocolList()
  13.     clearMonitor()
  14.     print("== RA-v Network ==")
  15.     print("")
  16.     textutils.slowPrint("Accessing protocols requires administrator access. Please enter the password")
  17.     print("")
  18.     print("Password : ")
  19.     id,message = rednet.receive()
  20.  
  21.     while true do
  22.         if id == 255 and message == "Tommy2002%" then
  23.             textutils.slowPrint("Password accepted")
  24.             sleep(2)
  25.             break
  26.         elseif id == 255 and message == "back" then
  27.         else
  28.             textutils.slowPrint("Password denied")
  29.         end
  30.     end
  31. end
  32.  
  33. clearMonitor()
  34. textutils.slowPrint("Loading system diagnostics..")
  35. sleep(1.5)
  36. textutils.slowPrint("Welcome to the RA-v Network")
  37. sleep(1)
  38.  
  39. while true do
  40.     clearMonitor()
  41.     print("== RA-v Network ==")
  42.     print("")
  43.     textutils.slowPrint(" = #1 S-CLASS REACTOR =")
  44.     textutils.slowPrint("   Core Heat - ...")
  45.     textutils.slowPrint("   Output - ...")
  46.     textutils.slowPrint("   Status - ...")
  47.     textutils.slowPrint("")
  48.     textutils.slowPrint(" = #2 H-CLASS REACTOR =")
  49.     textutils.slowPrint("   Core Heat - ...")
  50.     textutils.slowPrint("   Output - ...")
  51.     textutils.slowPrint("   Status - ...")
  52.     textutils.slowPrint("")
  53.     textutils.slowPrint(" = ME System =")
  54.     textutils.slowPrint("   Capacity - ...")
  55.     textutils.slowPrint("   Bandwidth - ...")
  56.     print("")
  57.     textutils.slowPrint("Enter a command from the terminal")
  58.    
  59.     rednet.send(35, "send.data") -- Reactor
  60.     rID,rMessage = rednet.receive()
  61.     rednet.send(73, "send.data") -- Reactor 2
  62.     hID,hMessage = rednet.receive()
  63.     rednet.send(36, "send.data") -- ME System
  64.     aID,aMessage = rednet.receive()
  65.  
  66.     while true do
  67.  
  68.         if rID == 35 then
  69.             rData = textutils.unserialise(rMessage)
  70.             rHeat = rData[1]
  71.             rOutput = rData[2]
  72.             rStatus = rData[3]
  73.         else
  74.             print("Received wrong id")
  75.         end
  76.         if hID == 73 then
  77.             hData = textutils.unserialise(hMessage)
  78.             hHeat = hData[1]
  79.             hOutput = hData[2]
  80.             hStatus = hData[3]
  81.         else
  82.             print("Received wrong id")
  83.         end
  84.         if aID == 36 then
  85.             aData = textutils.unserialise(aMessage)
  86.             aCapacity = aData[1]
  87.             aEnergy = aData[2]
  88.         else
  89.             print("Received wrong id")
  90.         end
  91.         if id == 255 and message == "protocol" then
  92.             rednet.send("protocol.start")
  93.         end
  94.  
  95.         if rStatus == true then
  96.             rDStatus = "Online"
  97.         elseif rStatus == false then
  98.             rDStatus = "Offline"
  99.         else
  100.             print("Failed to getReactorStatus")
  101.         end
  102.         if hStatus == true then
  103.             hDStatus = "Online"
  104.         elseif hStatus == false then
  105.             hDStatus = "Offline"
  106.         else
  107.             print("Failed to getReactorStatus")
  108.         end
  109.  
  110.         rDHeat = tostring(math.floor((rHeat/10000)*100))
  111.         hDHeat = tostring(math.floor((hHeat/10000)*100))
  112.  
  113.         clearMonitor()
  114.         print("== RA-v Network ==")
  115.         print("")
  116.         print(" = #1 S-CLASS REACTOR =")
  117.         print("   Core Heat - " .. rDHeat .. "%")
  118.         print("   Output - " .. rOutput .. " EU/t")
  119.         print("   Status - " .. rDStatus)
  120.         print("")
  121.         print(" = #2 H-CLASS REACTOR =")
  122.         print("   Core Heat - " .. hDHeat .. "%")
  123.         print("   Output - " .. hOutput .. " EU/t")
  124.         print("   Status - " .. hDStatus)
  125.         print("")
  126.         print(" = ME System =")
  127.         print("   Capacity - " .. aCapacity .. "i")
  128.         print("   Bandwidth - " .. aEnergy .. " AE/t")
  129.         print("")
  130.         print("Enter a command from the terminal")
  131.  
  132.         rednet.send(35,"send.data") -- Reactor
  133.         rID,rMessage = rednet.receive()
  134.         rednet.send(73, "send.data") -- Reactor 2
  135.         hID,hMessage = rednet.receive()
  136.         rednet.send(36,"send.data") -- ME System
  137.         aID,aMessage = rednet.receive()
  138.  
  139.         sleep(0.5)
  140.     end
  141.  
  142.     clearMonitor()
  143.     textutils.slowPrint("Accessed Menu")
  144.     sleep(0.5)
  145.     print("Commands are available")
  146.     while true do
  147.         id,message = rednet.receive()
  148.         if id == 255 and message == "jebus" then
  149.             break
  150.         else
  151.             textutils.slowPrint("Unknown command")
  152.             sleep(5)
  153.         end
  154.     end
  155.     clearMonitor()
  156.     textutils.slowPrint("All hail Jewish Jebus")
  157.     sleep(5)
  158. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement