SHOW:
|
|
- or go back to the newest paste.
| 1 | local backColor = colors.white | |
| 2 | local Name = "" | |
| 3 | local UID = "" | |
| 4 | ||
| 5 | function ManualInstall() | |
| 6 | local loop = true | |
| 7 | local e,b,x,y | |
| 8 | local click = false | |
| 9 | local ErrMsg = "" | |
| 10 | local Msg = "" | |
| 11 | while(loop) do | |
| 12 | parallel.waitForAny( | |
| 13 | --GUI | |
| 14 | function() | |
| 15 | term.setBackgroundColor(backColor) | |
| 16 | term.clear() | |
| 17 | ||
| 18 | --Title | |
| 19 | paintutils.drawPixel(4,2, backColor) | |
| 20 | term.setCursorPos(4,2) | |
| 21 | term.setTextColor(colors.black) | |
| 22 | term.write("-Code Download-")
| |
| 23 | ||
| 24 | --Return Button | |
| 25 | paintutils.drawPixel(2,2, colors.red) | |
| 26 | term.setCursorPos(2,2) | |
| 27 | term.setTextColor(colors.white) | |
| 28 | term.write("<")
| |
| 29 | ||
| 30 | --UID TextBox | |
| 31 | paintutils.drawPixel(2,4, backColor) | |
| 32 | term.setCursorPos(2,4) | |
| 33 | term.setTextColor(colors.black) | |
| 34 | term.write("UID")
| |
| 35 | paintutils.drawLine(2,5,11,5,colors.black) | |
| 36 | term.setCursorPos(2,5) | |
| 37 | term.setTextColor(colors.white) | |
| 38 | term.write(UID) | |
| 39 | ||
| 40 | --Name TextBox | |
| 41 | paintutils.drawPixel(2,7, backColor) | |
| 42 | term.setCursorPos(2,7) | |
| 43 | term.setTextColor(colors.black) | |
| 44 | term.write("Name")
| |
| 45 | paintutils.drawLine(2,8,11,8,colors.black) | |
| 46 | term.setCursorPos(2,8) | |
| 47 | term.setTextColor(colors.white) | |
| 48 | term.write(Name) | |
| 49 | ||
| 50 | --Download Button | |
| 51 | paintutils.drawPixel(2,10, colors.green) | |
| 52 | term.setCursorPos(2,10) | |
| 53 | term.setTextColor(colors.black) | |
| 54 | term.write("Download")
| |
| 55 | ||
| 56 | --Messages | |
| 57 | if (ErrMsg ~= "") then | |
| 58 | paintutils.drawPixel(2,12, backColor) | |
| 59 | term.setCursorPos(2,12) | |
| 60 | term.setTextColor(colors.red) | |
| 61 | term.write(ErrMsg) | |
| 62 | elseif (Msg ~= "") then | |
| 63 | paintutils.drawPixel(2,12, backColor) | |
| 64 | term.setCursorPos(2,12) | |
| 65 | term.setTextColor(colors.green) | |
| 66 | term.write(Msg) | |
| 67 | end | |
| 68 | ||
| 69 | sleep(2) | |
| 70 | end, | |
| 71 | function() | |
| 72 | e,b,x,y = os.pullEvent("mouse_click")
| |
| 73 | click = true | |
| 74 | end | |
| 75 | ) | |
| 76 | ||
| 77 | if (click==true) then | |
| 78 | if (x==2 and y==2) then | |
| 79 | loop = false | |
| 80 | elseif (y==5 and x>=2 and x<=11) then | |
| 81 | paintutils.drawPixel(2,5, colors.black) | |
| 82 | term.setCursorPos(2,5) | |
| 83 | term.setTextColor(colors.white) | |
| 84 | UID = read() | |
| 85 | elseif (y==8 and x>=2 and x<=11) then | |
| 86 | paintutils.drawPixel(2,8, colors.black) | |
| 87 | term.setCursorPos(2,8) | |
| 88 | term.setTextColor(colors.white) | |
| 89 | Name = read() | |
| 90 | elseif (y==10 and x>=2 and x<=9) then | |
| 91 | if (Name == "" or UID == "") then | |
| 92 | Msg = "" | |
| 93 | ErrMsg = "Missing info!" | |
| 94 | elseif (fs.exists("Apps/" .. Name)) then
| |
| 95 | Msg = "" | |
| 96 | ErrMsg = "Name already in use!" | |
| 97 | else | |
| 98 | term.setTextColor(colors.white) | |
| 99 | shell.run("pastebin", "get", UID, "Apps/" .. Name .. "/" .. Name .. ".lua")
| |
| 100 | local fUID = fs.open("Apps/" .. Name .. "/UID.txt", "w")
| |
| 101 | fUID.write(UID) | |
| 102 | fUID.close() | |
| 103 | Msg = "Download successful!" | |
| 104 | ErrMsg = "" | |
| 105 | end | |
| 106 | end | |
| 107 | click = false | |
| 108 | end | |
| 109 | end | |
| 110 | end | |
| 111 | ||
| 112 | function DeleteApp() | |
| 113 | local lsApps = {}
| |
| 114 | local loop = true | |
| 115 | while(loop) do | |
| 116 | --GUI | |
| 117 | term.setBackgroundColor(backColor) | |
| 118 | term.clear() | |
| 119 | ||
| 120 | --Title | |
| 121 | paintutils.drawPixel(4,2, backColor) | |
| 122 | term.setCursorPos(4,2) | |
| 123 | term.setTextColor(colors.black) | |
| 124 | term.write("-Delete Apps-")
| |
| 125 | ||
| 126 | --Return Button | |
| 127 | paintutils.drawPixel(2,2, colors.red) | |
| 128 | term.setCursorPos(2,2) | |
| 129 | term.setTextColor(colors.white) | |
| 130 | term.write("<")
| |
| 131 | ||
| 132 | local i = 4 | |
| 133 | for _, file in ipairs(fs.list("Apps")) do
| |
| 134 | if (file~="Market" and file~="Options") then | |
| 135 | paintutils.drawPixel(2,i, colors.red) | |
| 136 | term.setCursorPos(2,i) | |
| 137 | term.setTextColor(colors.white) | |
| 138 | term.write(file) | |
| 139 | ||
| 140 | lsApps[i]=file | |
| 141 | ||
| 142 | i=i+2 | |
| 143 | end | |
| 144 | end | |
| 145 | ||
| 146 | --Click Buttons | |
| 147 | local e,b,x,y = os.pullEvent("mouse_click")
| |
| 148 | ||
| 149 | if (x==2 and y==2) then | |
| 150 | loop = false | |
| 151 | else | |
| 152 | local xLen = string.len(lsApps[y]) | |
| 153 | if (x>=2 and x<=xLen+1) then | |
| 154 | fs.delete("Apps/" .. lsApps[y])
| |
| 155 | end | |
| 156 | end | |
| 157 | end | |
| 158 | end | |
| 159 | ||
| 160 | function UpdateApp() | |
| 161 | local lsApps = {}
| |
| 162 | local loop = true | |
| 163 | while(loop) do | |
| 164 | --GUI | |
| 165 | term.setBackgroundColor(backColor) | |
| 166 | term.clear() | |
| 167 | ||
| 168 | --Title | |
| 169 | paintutils.drawPixel(4,2, backColor) | |
| 170 | term.setCursorPos(4,2) | |
| 171 | term.setTextColor(colors.black) | |
| 172 | term.write("-Delete Apps-")
| |
| 173 | ||
| 174 | --Return Button | |
| 175 | paintutils.drawPixel(2,2, colors.red) | |
| 176 | term.setCursorPos(2,2) | |
| 177 | term.setTextColor(colors.white) | |
| 178 | term.write("<")
| |
| 179 | ||
| 180 | local i = 4 | |
| 181 | for _, file in ipairs(fs.list("Apps")) do
| |
| 182 | paintutils.drawPixel(2,i, colors.yellow) | |
| 183 | term.setCursorPos(2,i) | |
| 184 | term.setTextColor(colors.white) | |
| 185 | term.write(file) | |
| 186 | ||
| 187 | lsApps[i]=file | |
| 188 | ||
| 189 | i=i+2 | |
| 190 | end | |
| 191 | ||
| 192 | --Click Buttons | |
| 193 | local e,b,x,y = os.pullEvent("mouse_click")
| |
| 194 | ||
| 195 | if (x==2 and y==2) then | |
| 196 | loop = false | |
| 197 | else | |
| 198 | local xLen = string.len(lsApps[y]) | |
| 199 | if (x>=2 and x<=xLen+1) then | |
| 200 | fs.delete("Apps/" .. lsApps[y] .. "/" .. lsApps[y] .. ".lua")
| |
| 201 | local fUID = fs.open("Apps/" .. lsApps[y] .. "/UID.txt", "r")
| |
| 202 | shell.run("pastebin", "get",fUID.readLine() , "Apps/" .. lsApps[y] .. "/" .. lsApps[y] .. ".lua")
| |
| 203 | end | |
| 204 | end | |
| 205 | end | |
| 206 | end | |
| 207 | ||
| 208 | function BrowseApps() | |
| 209 | ||
| 210 | end | |
| 211 | ||
| 212 | function EventsMain(x,y) | |
| 213 | if (x==2 and y==2) then --Exit | |
| 214 | error("",0)
| |
| 215 | elseif (x>=2 and x<=10 and y==4) then --Manual | |
| 216 | ManualInstall() | |
| 217 | elseif (x>=2 and x<=8 and y==6) then --Browse | |
| 218 | BrowseApps() | |
| 219 | elseif (x>=2 and x<=12 and y==8) then --Delete | |
| 220 | DeleteApp() | |
| 221 | elseif (x>=2 and x<=12 and y==10) then --Update | |
| 222 | UpdateApp() | |
| 223 | elseif (x>2 and x<=10 and y==18) then --Update OS | |
| 224 | fs.delete("startup.lua")
| |
| 225 | - | shell.run("pastebin", "get", "Yir91aUq", "startup.lua")
|
| 225 | + | shell.run("pastebin", "get", "FHjcaBvz", "startup.lua")
|
| 226 | os.reboot() | |
| 227 | end | |
| 228 | end | |
| 229 | ||
| 230 | function GuiMain() | |
| 231 | term.setBackgroundColor(backColor) | |
| 232 | term.clear() | |
| 233 | ||
| 234 | --Title | |
| 235 | term.setTextColor(colors.black) | |
| 236 | term.setCursorPos(6,2) | |
| 237 | term.write("-App Market-")
| |
| 238 | ||
| 239 | --Exit Button | |
| 240 | term.setTextColor(colors.white) | |
| 241 | paintutils.drawPixel(2,2,colors.red) | |
| 242 | term.setCursorPos(2,2) | |
| 243 | term.write("x")
| |
| 244 | ||
| 245 | --Manual Button | |
| 246 | term.setTextColor(colors.white) | |
| 247 | paintutils.drawLine(2, 4, 9, 4, colors.yellow) | |
| 248 | term.setCursorPos(2,4) | |
| 249 | term.write("Use code")
| |
| 250 | ||
| 251 | --Browse Button | |
| 252 | term.setTextColor(colors.white) | |
| 253 | paintutils.drawLine(2, 6, 7, 6, colors.yellow) | |
| 254 | term.setCursorPos(2,6) | |
| 255 | term.write("Browse")
| |
| 256 | ||
| 257 | --Delete Button | |
| 258 | term.setTextColor(colors.white) | |
| 259 | paintutils.drawLine(2, 8, 12, 8, colors.red) | |
| 260 | term.setCursorPos(2,8) | |
| 261 | term.write("Delete Apps")
| |
| 262 | ||
| 263 | --Delete Button | |
| 264 | term.setTextColor(colors.white) | |
| 265 | paintutils.drawLine(2, 10, 12, 10, colors.yellow) | |
| 266 | term.setCursorPos(2,10) | |
| 267 | term.write("Update Apps")
| |
| 268 | ||
| 269 | --Delete Button | |
| 270 | term.setTextColor(colors.white) | |
| 271 | paintutils.drawLine(2, 18, 10, 18, colors.orange) | |
| 272 | term.setCursorPos(2,18) | |
| 273 | term.write("Update OS")
| |
| 274 | end | |
| 275 | ||
| 276 | -- Main -- | |
| 277 | local click = false | |
| 278 | while(true) do | |
| 279 | local e,b,x,y | |
| 280 | parallel.waitForAny( | |
| 281 | function() | |
| 282 | GuiMain() | |
| 283 | sleep(2) | |
| 284 | end, | |
| 285 | function() | |
| 286 | e,b,x,y = os.pullEvent("mouse_click")
| |
| 287 | click = true | |
| 288 | end) | |
| 289 | ||
| 290 | if (click) then | |
| 291 | click = false | |
| 292 | EventsMain(x,y) | |
| 293 | end | |
| 294 | end |