SHOW:
|
|
- or go back to the newest paste.
| 1 | term.setBackgroundColor(colors.white) | |
| 2 | term.clear() | |
| 3 | ||
| 4 | -- Sistemo le funzioni per tutto | |
| 5 | function header(text, color) | |
| 6 | term.setBackgroundColor(colors[color]) | |
| 7 | term.setTextColor(colors.white) | |
| 8 | term.setCursorPos(15, 1) | |
| 9 | print(text) | |
| 10 | end | |
| 11 | ||
| 12 | function button(x, y, text, color, bkcolor) | |
| 13 | term.setBackgroundColor(colors[bkcol]) | |
| 14 | term.setTextColor(colors[color]) | |
| 15 | term.setCursorPos(x, y) | |
| 16 | print(text) | |
| 17 | end | |
| 18 | ||
| 19 | function text(text, color) | |
| 20 | term.setBackgroundColor(colors.white) | |
| 21 | term.setTextColor(colors[color]) | |
| 22 | print(text) | |
| 23 | end | |
| 24 | ||
| 25 | function n(col) | |
| 26 | term.setBackgroundColor(colors.white) | |
| 27 | term.setTextColor(colors[col]) | |
| 28 | end | |
| 29 | ||
| 30 | function popupPos(aa) | |
| 31 | term.setCursorPos(5, aa) | |
| 32 | end | |
| 33 | ||
| 34 | function popup(text, text1, text2, text3, text4, text5) --TEXT = MAX 15 - MM = MAX 15 | |
| 35 | drawFilledBox(5, 2, 27, 9, colours.grey) | |
| 36 | term.setTextColor(colors.white) | |
| 37 | term.setCursorPos(5, 2) | |
| 38 | print("|---------------------|")
| |
| 39 | term.setCursorPos(5, 3) | |
| 40 | print(text) | |
| 41 | popupPos(4) | |
| 42 | print(text1) | |
| 43 | popupPos(5) | |
| 44 | print(text2) | |
| 45 | popupPos(6) | |
| 46 | print(text3) | |
| 47 | popupPos(7) | |
| 48 | print(text4) | |
| 49 | popupPos(8) | |
| 50 | print(text5) | |
| 51 | term.setCursorPos(5, 9) | |
| 52 | print("|---------------------|")
| |
| 53 | end | |
| 54 | ||
| 55 | local function drawPixelInternal(xPos, yPos) | |
| 56 | term.setCursorPos(xPos, yPos) | |
| 57 | term.write(" ")
| |
| 58 | end | |
| 59 | ||
| 60 | local tColourLookup = {}
| |
| 61 | for n = 1, 16 do | |
| 62 | tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
| |
| 63 | end | |
| 64 | ||
| 65 | function drawFilledBox(startX, startY, endX, endY, nColour) | |
| 66 | if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~= | |
| 67 | "number" or type(endY) ~= "number" or | |
| 68 | (nColour ~= nil and type(nColour) ~= "number") then | |
| 69 | error("Expected startX, startY, endX, endY, colour", 2)
| |
| 70 | end | |
| 71 | ||
| 72 | startX = math.floor(startX) | |
| 73 | startY = math.floor(startY) | |
| 74 | endX = math.floor(endX) | |
| 75 | endY = math.floor(endY) | |
| 76 | ||
| 77 | if nColour then term.setBackgroundColor(nColour) end | |
| 78 | if startX == endX and startY == endY then | |
| 79 | drawPixelInternal(startX, startY) | |
| 80 | return | |
| 81 | end | |
| 82 | ||
| 83 | local minX = math.min(startX, endX) | |
| 84 | if minX == startX then | |
| 85 | minY = startY | |
| 86 | maxX = endX | |
| 87 | maxY = endY | |
| 88 | else | |
| 89 | minY = endY | |
| 90 | maxX = startX | |
| 91 | maxY = startY | |
| 92 | end | |
| 93 | ||
| 94 | for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end | |
| 95 | end | |
| 96 | ||
| 97 | popup("DIOPOCO", "aa", "aa", "a", "a", "a")
| |
| 98 |