MrDionesalvi

Untitled

Oct 1st, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. local function drawPixelInternal(xPos, yPos)
  2. term.setCursorPos(xPos, yPos)
  3. term.write(" ")
  4. end
  5.  
  6. local tColourLookup = {}
  7. for n = 1, 16 do
  8. tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  9. end
  10.  
  11. function drawFilledBox(startX, startY, endX, endY, nColour)
  12. if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  13. "number" or type(endY) ~= "number" or
  14. (nColour ~= nil and type(nColour) ~= "number") then
  15. error("Expected startX, startY, endX, endY, colour", 2)
  16. end
  17.  
  18. startX = math.floor(startX)
  19. startY = math.floor(startY)
  20. endX = math.floor(endX)
  21. endY = math.floor(endY)
  22.  
  23. if nColour then term.setBackgroundColor(nColour) end
  24. if startX == endX and startY == endY then
  25. drawPixelInternal(startX, startY)
  26. return
  27. end
  28.  
  29. local minX = math.min(startX, endX)
  30. if minX == startX then
  31. minY = startY
  32. maxX = endX
  33. maxY = endY
  34. else
  35. minY = endY
  36. maxX = startX
  37. maxY = startY
  38. end
  39.  
  40. for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  41. end
  42.  
  43. function colore(nome) term.setTextColor(nome) end
  44.  
  45. function sfondo(nome) term.setBackgroundColor(nome) end
  46.  
  47. function fineColore() term.setTextColour(colours.white) end
  48.  
  49. function fineSfondo() term.setBackgroundColour(colours.black) end
  50.  
  51. function titolo(testo)
  52. drawFilledBox(1, 1, maxw, 1, colors.yellow)
  53. term.setCursorPos((maxw - #testo) / 2, 1)
  54. colore(colors.black)
  55. term.write(testo)
  56. sfondo(colors.blue)
  57. end
  58.  
  59. function clear()
  60. sfondo(colors.blue)
  61. term.clear()
  62. term.setCursorPos(1, 1)
  63. end
  64.  
  65. function errore(errore)
  66. sfondo(colors.red)
  67. colore(colors.white)
  68. term.clear()
  69. term.setCursorPos(1, 1)
  70. titolo("Errore irreversibile")
  71. term.setCursorPos(1, 3)
  72. sfondo(colors.red)
  73. colore(colors.white)
  74. print(errore)
  75. print("\n\n\nAttendere qualche secondo...")
  76. os.sleep(5)
  77. os.reboot()
  78. end
  79.  
  80.  
  81. sfondo(colors.white)
  82. term.clear()
  83. term.setCursorPos(1, 1)
  84. colore(colors.white)
  85. colore(colors.black)
  86. sfondo(colors.white)
  87. term.setCursorPos(14, 1)
  88. term.write("Registrazione partita IVA")
  89. colore(colors.white)
  90. sfondo(colors.lime)
  91. term.setCursorPos(31, 10)
  92. term.write("Registra una")
  93. term.setCursorPos(31, 11)
  94. term.write("partita")
  95. term.setCursorPos(31, 12)
  96. term.write("IVA")
Add Comment
Please, Sign In to add comment