Advertisement
lego11

Reattore Alfa Ritm display

Nov 7th, 2021 (edited)
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  2. local function drawPixelInternal(xPos, yPos)
  3. term.setCursorPos(xPos, yPos)
  4. term.write(" ")
  5. end
  6.  
  7. local tColourLookup = {}
  8. for n = 1, 16 do
  9. tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  10. end
  11.  
  12. function drawFilledBox(startX, startY, endX, endY, nColour)
  13. if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  14. "number" or type(endY) ~= "number" or
  15. (nColour ~= nil and type(nColour) ~= "number") then
  16. error("Expected startX, startY, endX, endY, colour", 2)
  17. end
  18.  
  19. startX = math.floor(startX)
  20. startY = math.floor(startY)
  21. endX = math.floor(endX)
  22. endY = math.floor(endY)
  23.  
  24. if nColour then term.setBackgroundColor(nColour) end
  25. if startX == endX and startY == endY then
  26. drawPixelInternal(startX, startY)
  27. return
  28. end
  29.  
  30. local minX = math.min(startX, endX)
  31. if minX == startX then
  32. minY = startY
  33. maxX = endX
  34. maxY = endY
  35. else
  36. minY = endY
  37. maxX = startX
  38. maxY = startY
  39. end
  40.  
  41. for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  42. end
  43.  
  44. function clear()
  45. term.clear()
  46. term.setCursorPos(1,1)
  47. end
  48. function colore(sfumatura) term.setTextColour(sfumatura) end
  49.  
  50. function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) end
  51.  
  52. function fineColore() term.setTextColour(colours.white) end
  53.  
  54. function fineSfondo() term.setBackgroundColour(colours.black) end
  55.  
  56. function titolo(testo)
  57. drawFilledBox(1, 1, 51, 1, colors.yellow)
  58. term.setCursorPos((51 - #testo) / 2, 1)
  59. colore(colors.black)
  60. term.write(testo)
  61. fineSfondo()
  62. fineColore()
  63. end
  64.  
  65. function footer()
  66. testo = "(C) Malakhit OKB - Aggiornato alle ore " .. textutils.formatTime(os.time(), true)
  67. drawFilledBox(1, 19, 51, 19, colors.yellow)
  68. term.setCursorPos((51 - #testo) / 2, 19)
  69. colore(colors.black)
  70. term.write(testo)
  71. fineSfondo()
  72. fineColore()
  73. end
  74.  
  75. clear()
  76. titolo("Sistema Ritm")
  77. term.setCursorPos(1, 3)
  78. print("Attesa collegamento")
  79. while true do
  80. rednet.open("bottom")
  81. senderID, rawMessage = rednet.receive(10)
  82. rednet.close("bottom")
  83. if rawMessage == nil or rawMessage == "" then
  84. titolo("Sistema Ritm")
  85. term.setCursorPos(1, 3)
  86. colore(colors.red)
  87. print("Errore di comunicazione - collegamento interrotto")
  88. sleep(5)
  89. os.reboot()
  90. end
  91. message = textutils.unserialize(rawMessage)
  92. if message.type ~= "SKALA-RITM" then
  93. titolo("Sistema Ritm")
  94. term.setCursorPos(1, 3)
  95. colore(colors.red)
  96. print("Errore di comunicazione - manomissione rilevata")
  97. sleep(5)
  98. os.reboot()
  99. end
  100. clear()
  101. titolo("Sistema Ritm")
  102. sleep(0.1)
  103. term.setCursorPos(1, 3)
  104. if message.lowUranium == true then
  105. colore(colors.yellow)
  106. print("AVVERENTEZA: Uranio in esaurimento")
  107. end
  108. if message.steamHeat == true then
  109. colore(colors.white)
  110. print("INFORMAZIONE: Vapore saturo riscaldam. disponibile")
  111. end
  112. if message.scram == true then
  113. colore(colors.red)
  114. print("GUASTO: Reattore in SCRAM")
  115. else
  116. colore(colors.white)
  117. print("INFORMAZIONE: Reattore in funzione")
  118. end
  119. if message.pumpsSeized == true then
  120. colore(colors.red)
  121. print("GUASTO GRAVE: Reattore danneggiato irreparabilmente")
  122. else
  123. colore(colors.white)
  124. print("INFORMAZIONE: Pompe circuito primario in funzione")
  125. end
  126. footer()
  127. sleep(5)
  128. end
  129.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement