Untitled

Oct 29th, 2020 (edited)
531
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. -- Calafrica Group System
2. -- Dione approva
3.
4. local monitor = peripheral.wrap( "left" )
5.
6. local maxw, maxh = term.getSize()
7.
8. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
9. local function drawPixelInternal(xPos, yPos)
10.     monitor.setCursorPos(xPos, yPos)
11.     monitor.write(" ")
12. end
13.
14. local tColourLookup = {}
15. for n = 1, 16 do
16.     tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
17. end
18.
19. function drawFilledBox(startX, startY, endX, endY, nColour)
20.     if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
21.         "number" or type(endY) ~= "number" or
22.         (nColour ~= nil and type(nColour) ~= "number") then
23.         error("Expected startX, startY, endX, endY, colour", 2)
24.     end
25.
26.     startX = math.floor(startX)
27.     startY = math.floor(startY)
28.     endX = math.floor(endX)
29.     endY = math.floor(endY)
30.
31.     if nColour then term.setBackgroundColor(nColour) end
32.     if startX == endX and startY == endY then
33.         drawPixelInternal(startX, startY)
34.         return
35.     end
36.
37.     local minX = math.min(startX, endX)
38.     if minX == startX then
39.         minY = startY
40.         maxX = endX
41.         maxY = endY
42.     else
43.         minY = endY
44.         maxX = startX
45.         maxY = startY
46.     end
47.
48.     for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
49. end
50.
51. function colore(nome) monitor.setTextColor(nome) end
52.
53. function sfondo(nome) monitor.setBackgroundColor(nome) end
54.
55. function fineColore() monitor.setTextColour(colours.white) end
56.
57. function fineSfondo() monitor.setBackgroundColour(colours.black) end
58.
59. function clear()
60.     sfondo(colors.blue)
61.     monitor.clear()
62.     monitor.setCursorPos(1, 1)
63. end
64.
65. function errore(errore)
66.     sfondo(colors.red)
67.     colore(colors.white)
68.     monitor.clear()
69.     monitor.setCursorPos(1, 1)
70.     titolo("Errore irreversibile")
71.     monitor.setCursorPos(1, 3)
72.     sfondo(colors.red)
73.     colore(colors.white)
74.     monitor.write(errore)
75.     monitor.write("\n\n\nAttendere qualche secondo...")
76.     os.sleep(5)
77.     os.reboot()
78. end
79.
80.
81. sfondo(colors.cyan)
82. titolo("Monitor Gestione EPCO")
RAW Paste Data