SHOW:
|
|
- or go back to the newest paste.
| 1 | --os.pullEvent = os.pullEventRaw | |
| 2 | ret1, ret2 = nil, nil --return for parallel functions | |
| 3 | ||
| 4 | textStart = 11 | |
| 5 | localver = "0.2" | |
| 6 | remotevercheck = http.get("http://infaknox.space/version")
| |
| 7 | remotever = remotevercheck.readAll() | |
| 8 | function drawHeader() | |
| 9 | -- Blue | |
| 10 | term.setTextColor(colors.blue) | |
| 11 | term.setCursorPos(3, 2) term.write("O")
| |
| 12 | term.setCursorPos(4,3) term.write("O")
| |
| 13 | -- Orange | |
| 14 | term.setTextColor(colors.orange) | |
| 15 | term.setCursorPos(3, 3) term.write("@")
| |
| 16 | -- Text | |
| 17 | term.setCursorPos(4, 2) term.write("InfaKnox Systems.")
| |
| 18 | term.setCursorPos(33, 3) term.write("discord.gg/R7edKN5")
| |
| 19 | -- Version Information | |
| 20 | term.setCursorPos(40, 2) term.write("Version: ")
| |
| 21 | term.setCursorPos(15, 19) term.write("http://InfaKnox.Space")
| |
| 22 | -- term.setBackgroundColor(colors.black) | |
| 23 | if remotever == localver then | |
| 24 | term.setTextColor(colors.lime) | |
| 25 | else | |
| 26 | term.setTextColor(colors.red) | |
| 27 | end | |
| 28 | term.setCursorPos(48, 2) term.write("0.2")
| |
| 29 | term.setTextColor(colors.white) | |
| 30 | term.setBackgroundColor(colors.black) | |
| 31 | ||
| 32 | ||
| 33 | end | |
| 34 | ||
| 35 | function drawButtons() | |
| 36 | term.setBackgroundColor(colors.lightGray) | |
| 37 | term.setCursorPos(3, textStart) term.write(" ")
| |
| 38 | term.setCursorPos(3, textStart + 2) term.write(" ")
| |
| 39 | term.setCursorPos(3, textStart + 4) term.write(" ")
| |
| 40 | term.setCursorPos(3, textStart + 6) term.write(" ")
| |
| 41 | ||
| 42 | term.setCursorPos(48, textStart) term.write(" ")
| |
| 43 | term.setCursorPos(48, textStart + 2) term.write(" ")
| |
| 44 | term.setCursorPos(48, textStart + 4) term.write(" ")
| |
| 45 | term.setCursorPos(48, textStart + 6) term.write(" ")
| |
| 46 | ||
| 47 | term.setBackgroundColor(colors.black) | |
| 48 | end | |
| 49 | ||
| 50 | function drawButton(button, text) | |
| 51 | local x, y | |
| 52 | - | -- if button == 1 then x = 6 y = textStart end |
| 52 | + | if button == 1 then x = 6 y = textStart term.setBackgroundColor(colors.lightGray) term.setCursorPos(3, textStart) term.write(" ") term.setBackgroundColor(colors.black) end
|
| 53 | - | if button == 1 then x = 6 y = textStart term.setBackgroundColor(colors.lightGray) term.setCursorPos(3, textStart) term.write(" ") term.setBackgroundColor(colors.black) end
|
| 53 | + | if button == 2 then x = 6 y = textStart + 2 term.setBackgroundColor(colors.lightGray) term.setCursorPos(3, y) term.write(" ") term.setBackgroundColor(colors.black) end
|
| 54 | - | if button == 2 then x = 6 y = textStart + 2 term.setBackgroundColor(colors.lightGray) term.setCursorPos(3, textStart) term.write(" ") term.setBackgroundColor(colors.black) end
|
| 54 | + | if button == 3 then x = 6 y = textStart + 4 term.setBackgroundColor(colors.lightGray) term.setCursorPos(3, y) term.write(" ") term.setBackgroundColor(colors.black) end
|
| 55 | - | if button == 3 then x = 6 y = textStart + 4 term.setBackgroundColor(colors.lightGray) term.setCursorPos(3, textStart) term.write(" ") term.setBackgroundColor(colors.black) end
|
| 55 | + | if button == 4 then x = 6 y = textStart + 6 term.setBackgroundColor(colors.lightGray) term.setCursorPos(3, y) term.write(" ") term.setBackgroundColor(colors.black) end
|
| 56 | - | if button == 4 then x = 6 y = textStart + 6 term.setBackgroundColor(colors.lightGray) term.setCursorPos(3, textStart) term.write(" ") term.setBackgroundColor(colors.black) end
|
| 56 | + | |
| 57 | if button == 5 then x = 47 - #text y = textStart term.setBackgroundColor(colors.lightGray) term.setCursorPos(48, textStart) term.write(" ") term.setBackgroundColor(colors.black) end
| |
| 58 | - | if button == 5 then x = 47 - #text y = textStart end |
| 58 | + | if button == 6 then x = 47 - #text y = textStart + 2 term.setBackgroundColor(colors.lightGray) term.setCursorPos(48, y) term.write(" ") term.setBackgroundColor(colors.black) end
|
| 59 | - | if button == 6 then x = 47 - #text y = textStart + 2 end |
| 59 | + | if button == 7 then x = 47 - #text y = textStart + 4 term.setBackgroundColor(colors.lightGray) term.setCursorPos(48, y) term.write(" ") term.setBackgroundColor(colors.black) end
|
| 60 | - | if button == 7 then x = 47 - #text y = textStart + 4 end |
| 60 | + | if button == 8 then x = 47 - #text y = textStart + 6 term.setBackgroundColor(colors.lightGray) term.setCursorPos(48, y) term.write(" ") term.setBackgroundColor(colors.black) end
|
| 61 | - | if button == 8 then x = 47 - #text y = textStart + 6 end |
| 61 | + | |
| 62 | term.setCursorPos(x, y) | |
| 63 | term.write(text) | |
| 64 | - | term.write(text) |
| 64 | + | |
| 65 | ||
| 66 | function drawError(error) | |
| 67 | -- Outer Triangle | |
| 68 | term.setBackgroundColor(colors.red) | |
| 69 | term.setCursorPos(12, textStart) term.write(" ")
| |
| 70 | term.setCursorPos(11, textStart + 1) term.write(" ")
| |
| 71 | term.setCursorPos(10, textStart + 2) term.write(" ")
| |
| 72 | term.setCursorPos(9, textStart + 3) term.write(" ")
| |
| 73 | term.setCursorPos(8, textStart + 4) term.write(" ")
| |
| 74 | term.setCursorPos(7, textStart + 5) term.write(" ")
| |
| 75 | term.setCursorPos(6, textStart + 6) term.write(" ")
| |
| 76 | ||
| 77 | term.setCursorPos(13, textStart + 1) term.write(" ")
| |
| 78 | term.setCursorPos(14, textStart + 2) term.write(" ")
| |
| 79 | term.setCursorPos(15, textStart + 3) term.write(" ")
| |
| 80 | term.setCursorPos(16, textStart + 4) term.write(" ")
| |
| 81 | term.setCursorPos(17, textStart + 5) term.write(" ")
| |
| 82 | ||
| 83 | -- Inner Triangle | |
| 84 | term.setBackgroundColor(colors.white) | |
| 85 | term.setCursorPos(12, textStart + 1) term.write(" ")
| |
| 86 | term.setCursorPos(11, textStart + 2) term.write(" ")
| |
| 87 | term.setCursorPos(10, textStart + 3) term.write(" ")
| |
| 88 | term.setCursorPos(9, textStart + 4) term.write(" ")
| |
| 89 | term.setCursorPos(8, textStart + 5) term.write(" ")
| |
| 90 | ||
| 91 | -- ! | |
| 92 | term.setBackgroundColor(colors.black) | |
| 93 | term.setCursorPos(12, textStart + 2) term.write(" ")
| |
| 94 | term.setCursorPos(12, textStart + 3) term.write(" ")
| |
| 95 | term.setCursorPos(12, textStart + 5) term.write(" ")
| |
| 96 | ||
| 97 | -- Text | |
| 98 | term.setBackgroundColor(colors.black) | |
| 99 | term.setCursorPos(20, textStart) term.write(error) | |
| 100 | ||
| 101 | term.setBackgroundColor(colors.black) | |
| 102 | end | |
| 103 | ||
| 104 | function center(y, sText) | |
| 105 | local w, h = term.getSize() | |
| 106 | x = math.max(math.floor((w - #sText) / 2), 0) | |
| 107 | term.setCursorPos(x, y) | |
| 108 | print(sText) | |
| 109 | return x | |
| 110 | end | |
| 111 | ||
| 112 | function waitForMouse() | |
| 113 | while true do | |
| 114 | local event, p1, p2, p3 = os.pullEvent("mouse_click")
| |
| 115 | if p1 == 1 then | |
| 116 | ret1, ret2 = p2, p3 | |
| 117 | return p2, p3 | |
| 118 | end | |
| 119 | end | |
| 120 | end | |
| 121 | ||
| 122 | function waitForButton() | |
| 123 | while true do | |
| 124 | local mx, my = waitForMouse() | |
| 125 | if my == textStart and mx >= 3 and mx <= 4 then ret1 = 1 return 1 end | |
| 126 | if my == textStart + 2 and mx >= 3 and mx <= 4 then ret1 = 2 return 2 end | |
| 127 | if my == textStart + 4 and mx >= 3 and mx <= 4 then ret1 = 3 return 3 end | |
| 128 | if my == textStart + 6 and mx >= 3 and mx <= 4 then ret1 = 4 return 4 end | |
| 129 | ||
| 130 | if my == textStart and mx >= 48 and mx <= 49 then ret1 = 5 return 5 end | |
| 131 | if my == textStart + 2 and mx >= 48 and mx <= 49 then ret1 = 6 return 6 end | |
| 132 | if my == textStart + 4 and mx >= 48 and mx <= 49 then ret1 = 7 return 7 end | |
| 133 | if my == textStart + 6 and mx >= 48 and mx <= 49 then ret1 = 8 return 8 end | |
| 134 | end | |
| 135 | end | |
| 136 | ||
| 137 | function waitForChar() | |
| 138 | while true do | |
| 139 | local event, p1 = os.pullEvent("char")
| |
| 140 | ret1 = p1 | |
| 141 | return p1 | |
| 142 | end | |
| 143 | end | |
| 144 | ||
| 145 | function waitForKey() | |
| 146 | while true do | |
| 147 | local event, p1 = os.pullEvent("key")
| |
| 148 | ret1 = p1 | |
| 149 | return p1 | |
| 150 | end | |
| 151 | end | |
| 152 | ||
| 153 | function waitForEnter() | |
| 154 | while true do | |
| 155 | local p1 = waitForKey() | |
| 156 | if p1 == 28 then | |
| 157 | return | |
| 158 | end | |
| 159 | end | |
| 160 | end | |
| 161 | ||
| 162 | function waitForDisk() | |
| 163 | while true do | |
| 164 | local event, p1 = os.pullEvent("disk")
| |
| 165 | return | |
| 166 | end | |
| 167 | end |