PICCIONENBERG

programma reattore (GPT test)

Jun 16th, 2023 (edited)
1,413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. local s = peripheral.wrap("bottom")
  2.  
  3. local function clear()
  4.     term.clear()
  5.     term.setCursorPos(1, 1)
  6. end
  7.  
  8. local function waitForInput()
  9.     print("Caricare il reattore e premere un tasto")
  10.     print("By Sevcon Atomic")
  11.     os.pullEvent("key")
  12.     clear()
  13. end
  14.  
  15. local function formatTime(time)
  16.     local hours = math.floor(time / 3600)
  17.     local minutes = math.floor((time % 3600) / 60)
  18.     local seconds = time % 60
  19.  
  20.     return string.format("%02d:%02d:%02d", hours, minutes, seconds)
  21. end
  22.  
  23. clear()
  24.  
  25. while true do
  26.     local uuid, state, title, tab = s.get(1)
  27.     if not tab then
  28.         print("Errore nella comunicazione con il reattore")
  29.         print("By Sevcon Atomic")
  30.         sleep(1)
  31.         clear()
  32.         return
  33.     end
  34.  
  35.     if tab.timeLeft == 0 then
  36.         waitForInput()
  37.     end
  38.  
  39.     clear()
  40.     print("Caricamento automatico materiale da arricchire in funzione")
  41.     print("Tempo rimanente: " .. formatTime(tab.timeLeft))
  42.     print("By Sevcon Atomic")
  43.     rs.setBundledOutput("back", 2)
  44.  
  45.     if tab.timeLeft < 10 then
  46.         clear()
  47.         rs.setBundledOutput("back", 32)
  48.         print("Attesa esaurimento uranio")
  49.         sleep(30)
  50.         print("Caricamento uranio")
  51.         rs.setBundledOutput("back", 1)
  52.         sleep(30)
  53.         clear()
  54.         rs.setBundledOutput("back", 0)
  55.     end
  56.  
  57.     sleep(1)
  58. end
  59.  
Advertisement
Add Comment
Please, Sign In to add comment