Advertisement
MrDionesalvi

Untitled

Oct 1st, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. local maxw, maxh = term.getSize()
  2.  
  3. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  4. local function drawPixelInternal(xPos, yPos)
  5. term.setCursorPos(xPos, yPos)
  6. term.write(" ")
  7. end
  8.  
  9. local tColourLookup = {}
  10. for n = 1, 16 do
  11. tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  12. end
  13.  
  14. function drawFilledBox(startX, startY, endX, endY, nColour)
  15. if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  16. "number" or type(endY) ~= "number" or
  17. (nColour ~= nil and type(nColour) ~= "number") then
  18. error("Expected startX, startY, endX, endY, colour", 2)
  19. end
  20.  
  21. startX = math.floor(startX)
  22. startY = math.floor(startY)
  23. endX = math.floor(endX)
  24. endY = math.floor(endY)
  25.  
  26. if nColour then term.setBackgroundColor(nColour) end
  27. if startX == endX and startY == endY then
  28. drawPixelInternal(startX, startY)
  29. return
  30. end
  31.  
  32. local minX = math.min(startX, endX)
  33. if minX == startX then
  34. minY = startY
  35. maxX = endX
  36. maxY = endY
  37. else
  38. minY = endY
  39. maxX = startX
  40. maxY = startY
  41. end
  42.  
  43. for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  44. end
  45.  
  46. function colore(nome) term.setTextColor(nome) end
  47.  
  48. function sfondo(nome) term.setBackgroundColor(nome) end
  49.  
  50. function fineColore() term.setTextColour(colours.white) end
  51.  
  52. function fineSfondo() term.setBackgroundColour(colours.black) end
  53.  
  54. function titolo(testo)
  55. drawFilledBox(1, 1, maxw, 1, colors.yellow)
  56. term.setCursorPos((maxw - #testo) / 2, 1)
  57. colore(colors.black)
  58. term.write(testo)
  59. sfondo(colors.blue)
  60. end
  61.  
  62. function clear()
  63. sfondo(colors.blue)
  64. term.clear()
  65. term.setCursorPos(1, 1)
  66. end
  67.  
  68. function errore(errore)
  69. sfondo(colors.red)
  70. colore(colors.white)
  71. term.clear()
  72. term.setCursorPos(1, 1)
  73. titolo("Errore irreversibile")
  74. term.setCursorPos(1, 3)
  75. sfondo(colors.red)
  76. colore(colors.white)
  77. print(errore)
  78. print("\n\n\nAttendere qualche secondo...")
  79. os.sleep(5)
  80. os.reboot()
  81. end
  82.  
  83.  
  84. sfondo(colors.white)
  85. term.clear()
  86. term.setCursorPos(1, 1)
  87. colore(colors.white)
  88. colore(colors.black)
  89. sfondo(colors.white)
  90. term.setCursorPos(14, 1)
  91. term.write("Registrazione partita IVA")
  92. colore(colors.white)
  93. sfondo(colors.lime)
  94. term.setCursorPos(25, 10)
  95. term.write("Registra una")
  96. term.setCursorPos(25, 11)
  97. term.write("partita")
  98. term.setCursorPos(25, 12)
  99. term.write("IVA")
  100.  
  101.  
  102. while true do
  103. local event, par1, par2, par3 = os.pullEvent("mouse_click")
  104. if par2 >= 25 and par2 <= 37 and par3 >= 10 and par3 <= 12 then
  105. sfondo(colours.blue)
  106. term.clear()
  107. term.setCursorPos(1, 1)
  108. titolo("Registrazione Partita IVA")
  109. sfondo(colours.blue)
  110. colore(colors.white)
  111. print("\n\nInserire i propri dati. Premere Enter per confermare i dati inseriti.")
  112.  
  113. term.setCursorPos(1,9)
  114. term.write("Intestazione PIVA: ")
  115. intestazione = read()
  116. term.setCursorPos(1,11)
  117. term.write("Nome Intestatario: ")
  118. nome = read()
  119. term.setCursorPos(1,13)
  120. term.write("Sede Legale: ")
  121. pos = read()
  122. term.setCursorPos(1,15)
  123. term.write("Data di apertura: ")
  124. data = read()
  125. end
  126. sleep(0.1)
  127. end
  128.  
  129.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement