SHOW:
|
|
- or go back to the newest paste.
| 1 | rednet.open("back")
| |
| 2 | ||
| 3 | -- LUL | |
| 4 | ||
| 5 | ||
| 6 | maxw, maxh = term.getSize() | |
| 7 | local function drawPixelInternal(xPos, yPos) | |
| 8 | term.setCursorPos(xPos, yPos) | |
| 9 | term.write(" ")
| |
| 10 | end | |
| 11 | ||
| 12 | local tColourLookup = {}
| |
| 13 | for n = 1, 16 do | |
| 14 | tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
| |
| 15 | end | |
| 16 | ||
| 17 | function drawFilledBox(startX, startY, endX, endY, nColour) | |
| 18 | if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~= | |
| 19 | - | while true do |
| 19 | + | "number" or type(endY) ~= "number" or |
| 20 | (nColour ~= nil and type(nColour) ~= "number") then | |
| 21 | error("Expected startX, startY, endX, endY, colour", 2)
| |
| 22 | end | |
| 23 | ||
| 24 | startX = math.floor(startX) | |
| 25 | startY = math.floor(startY) | |
| 26 | endX = math.floor(endX) | |
| 27 | endY = math.floor(endY) | |
| 28 | ||
| 29 | if nColour then term.setBackgroundColor(nColour) end | |
| 30 | if startX == endX and startY == endY then | |
| 31 | drawPixelInternal(startX, startY) | |
| 32 | return | |
| 33 | end | |
| 34 | ||
| 35 | local minX = math.min(startX, endX) | |
| 36 | if minX == startX then | |
| 37 | minY = startY | |
| 38 | maxX = endX | |
| 39 | maxY = endY | |
| 40 | else | |
| 41 | minY = endY | |
| 42 | maxX = startX | |
| 43 | maxY = startY | |
| 44 | end | |
| 45 | ||
| 46 | for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end | |
| 47 | end | |
| 48 | ||
| 49 | function clear() | |
| 50 | sfondo(colors.black) | |
| 51 | term.clear() | |
| 52 | term.setCursorPos(1, 1) | |
| 53 | end | |
| 54 | ||
| 55 | function clearRed() | |
| 56 | sfondo(colors.red) | |
| 57 | term.clear() | |
| 58 | term.setCursorPos(1, 1) | |
| 59 | end | |
| 60 | ||
| 61 | function titolo(testo) | |
| 62 | drawFilledBox(1, 1, maxw, 1, colors.blue) | |
| 63 | term.setCursorPos((maxw - #testo) / 2, 1) | |
| 64 | term.setTextColor(colors.white) | |
| 65 | term.write(testo) | |
| 66 | end | |
| 67 | ||
| 68 | function alarm(testo, colore, y) | |
| 69 | drawFilledBox(1, y, maxw, y, colors[colore]) | |
| 70 | term.setCursorPos((maxw - #testo) / 2, y) | |
| 71 | term.setTextColor(colors.white) | |
| 72 | term.write(testo) | |
| 73 | no() | |
| 74 | end | |
| 75 | ||
| 76 | ||
| 77 | function bottone(color, text, x, y) | |
| 78 | term.setBackgroundColor(colors[color]) | |
| 79 | term.setTextColor(colors.white) | |
| 80 | term.setCursorPos(x, y) | |
| 81 | print(text) | |
| 82 | end | |
| 83 | ||
| 84 | function no() | |
| 85 | term.setBackgroundColor(colors.white) | |
| 86 | term.setTextColor(colors.black) | |
| 87 | end | |
| 88 | ||
| 89 | p = peripheral.wrap("bottom")
| |
| 90 | ||
| 91 | while true do | |
| 92 | local a, b, c, b1 = p.get(1) | |
| 93 | b1 = b1.energyL | |
| 94 | local a, b, c, b2 = p.get(2) | |
| 95 | b2 = b2.energyL | |
| 96 | local a, b, c, b3 = p.get(3) | |
| 97 | b3 = b3.energyL | |
| 98 | local a, b, c, b4 = p.get(4) | |
| 99 | b4 = b4.energyL | |
| 100 | local a, b, c, b5 = p.get(5) | |
| 101 | b5 = b5.energyL | |
| 102 | local a, b, c, b6 = p.get(6) | |
| 103 | b6 = b6.energyL | |
| 104 | ||
| 105 | if b1 < 500000 then | |
| 106 | color1 = "red" | |
| 107 | text1 = "Low Power" | |
| 108 | elseif b1 < 1000000 then | |
| 109 | color1 = "orange" | |
| 110 | text1 = "Low Power" | |
| 111 | elseif b1 < 5000000 then | |
| 112 | color1 = "yellow" | |
| 113 | text1 = "Good Power" | |
| 114 | elseif b1 > 7500000 then | |
| 115 | color1 = "green" | |
| 116 | text1 = "Wonderful Power" | |
| 117 | else | |
| 118 | color1 = "gray" | |
| 119 | text1 = "ERROR" | |
| 120 | end | |
| 121 | ||
| 122 | if b2 < 500000 then | |
| 123 | color2 = "red" | |
| 124 | text2 = "Low Power" | |
| 125 | elseif b2 < 1000000 then | |
| 126 | color2 = "orange" | |
| 127 | text2 = "Low Power" | |
| 128 | elseif b2 < 5000000 then | |
| 129 | color2 = "yellow" | |
| 130 | text2 = "Good Power" | |
| 131 | elseif b2 > 7500000 then | |
| 132 | color2 = "green" | |
| 133 | text2 = "Wonderful Power" | |
| 134 | else | |
| 135 | color2 = "gray" | |
| 136 | text2 = "ERROR" | |
| 137 | end | |
| 138 | ||
| 139 | if b3 < 500000 then | |
| 140 | color3 = "red" | |
| 141 | text3 = "Low Power" | |
| 142 | elseif b1 < 1000000 then | |
| 143 | color3 = "orange" | |
| 144 | text3 = "Low Power" | |
| 145 | elseif b3 < 5000000 then | |
| 146 | color3 = "yellow" | |
| 147 | text3 = "Good Power" | |
| 148 | elseif b3 > 7500000 then | |
| 149 | color3 = "green" | |
| 150 | text3 = "Wonderful Power" | |
| 151 | else | |
| 152 | color3 = "gray" | |
| 153 | text3 = "ERROR" | |
| 154 | end | |
| 155 | ||
| 156 | if b4 < 500000 then | |
| 157 | color4 = "red" | |
| 158 | text4 = "Low Power" | |
| 159 | elseif b4 < 1000000 then | |
| 160 | color4 = "orange" | |
| 161 | text4 = "Low Power" | |
| 162 | elseif b4 < 5000000 then | |
| 163 | color4 = "yellow" | |
| 164 | text4 = "Good Power" | |
| 165 | elseif b4 > 7500000 then | |
| 166 | color4 = "green" | |
| 167 | text4 = "Wonderful Power" | |
| 168 | else | |
| 169 | color4 = "gray" | |
| 170 | text4 = "ERROR" | |
| 171 | end | |
| 172 | ||
| 173 | if b5 < 500000 then | |
| 174 | color5 = "red" | |
| 175 | text5 = "Low Power" | |
| 176 | elseif b5 < 1000000 then | |
| 177 | color5 = "orange" | |
| 178 | text5 = "Low Power" | |
| 179 | elseif b5 < 5000000 then | |
| 180 | color5 = "yellow" | |
| 181 | text5 = "Good Power" | |
| 182 | elseif b5 > 7500000 then | |
| 183 | color5 = "green" | |
| 184 | text5 = "Wonderful Power" | |
| 185 | else | |
| 186 | color5 = "gray" | |
| 187 | text5 = "ERROR" | |
| 188 | end | |
| 189 | ||
| 190 | if b6 < 500000 then | |
| 191 | color6 = "red" | |
| 192 | text6 = "Low Power" | |
| 193 | elseif b6 < 1000000 then | |
| 194 | color6 = "orange" | |
| 195 | text6 = "Low Power" | |
| 196 | elseif b6 < 5000000 then | |
| 197 | color6 = "yellow" | |
| 198 | text6 = "Good Power" | |
| 199 | elseif b6 > 7500000 then | |
| 200 | color6 = "green" | |
| 201 | text6 = "Wonderful Power" | |
| 202 | else | |
| 203 | color6 = "gray" | |
| 204 | text6 = "ERROR" | |
| 205 | end | |
| 206 | ||
| 207 | ||
| 208 | term.setBackgroundColor(colors.white) | |
| 209 | term.clear() | |
| 210 | titolo("Gestione Batterie - Titanus Elios")
| |
| 211 | no() | |
| 212 | print("\nBenvenuto nel centro di gestione delle batterie di Emergenza!")
| |
| 213 | term.setCursorPos(2, 4) | |
| 214 | print("Batteria 1")
| |
| 215 | term.setCursorPos(4, 5) | |
| 216 | term.setBackgroundColor(colors[color1]) | |
| 217 | print(" ")
| |
| 218 | no() | |
| 219 | print(text1) | |
| 220 | ||
| 221 | ||
| 222 | sleep(0.1) | |
| 223 | end | |
| 224 |