SHOW:
|
|
- or go back to the newest paste.
| 1 | --this is the BlueTunes program | |
| 2 | --copyright of BlueTide Programs.inc, Benedict Allen, all members of BlueTide Programs.inc and all members of programcraft.inc | |
| 3 | --if you wish to use this program please contact Benedict Allen(awsumben13 on cc forums) and make sure you give the credit to BlueTide Programs | |
| 4 | ||
| 5 | --usability functions | |
| 6 | ||
| 7 | local function clear() | |
| 8 | term.clear() | |
| 9 | term.setCursorPos(1,1) | |
| 10 | end | |
| 11 | ||
| 12 | local function clearPos(x,y) | |
| 13 | term.clear() | |
| 14 | term.setCursorPos(x,y) | |
| 15 | end | |
| 16 | ||
| 17 | local function printLine(x,y,text) | |
| 18 | term.setCursorPos(x,y) | |
| 19 | print(text) | |
| 20 | end | |
| 21 | ||
| 22 | function clearPrint(x,y,text) | |
| 23 | term.clear() | |
| 24 | term.setCursorPos(x,y) | |
| 25 | print(text) | |
| 26 | end | |
| 27 | ||
| 28 | function reset(file, x, y) | |
| 29 | if fs.exists(file) then | |
| 30 | h = fs.open(file, "w") | |
| 31 | h.write("")
| |
| 32 | h.close() | |
| 33 | term.setCursorPos(x,y) | |
| 34 | print("File reset")
| |
| 35 | sleep(2) | |
| 36 | else | |
| 37 | term.setCursorPos(x,y) | |
| 38 | print("file not found")
| |
| 39 | sleep(2) | |
| 40 | end | |
| 41 | end | |
| 42 | ||
| 43 | function tip(help) | |
| 44 | while true do | |
| 45 | clear() | |
| 46 | print(help) | |
| 47 | printLine(1,17,"press enter to exit") | |
| 48 | event, key = os.pullEvent() | |
| 49 | if key == 28 then break | |
| 50 | end | |
| 51 | end | |
| 52 | end | |
| 53 | ||
| 54 | function drawloading() | |
| 55 | print("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO")
| |
| 56 | print("O O")
| |
| 57 | ||
| 58 | print("O O")
| |
| 59 | ||
| 60 | print("O OOO O O O OOOO OOOO OOOO OOO OOOO O")
| |
| 61 | ||
| 62 | print("O O O O O O O OO OO O O O O")
| |
| 63 | ||
| 64 | print("O OOOO O O O OOOO OO OO O O OOOO O")
| |
| 65 | ||
| 66 | print("O O O O O O O OO OO O O O O")
| |
| 67 | ||
| 68 | print("O OOO OOOO OOO OOOO OO OOOO OOO OOOO O")
| |
| 69 | ||
| 70 | print("O O")
| |
| 71 | ||
| 72 | print("O systems.inc O")
| |
| 73 | ||
| 74 | print("O O")
| |
| 75 | ||
| 76 | print("O loading[ ] O")
| |
| 77 | ||
| 78 | print("O O")
| |
| 79 | ||
| 80 | print("O O")
| |
| 81 | ||
| 82 | print("O O")
| |
| 83 | ||
| 84 | print("O Made by: Benedict Allen O")
| |
| 85 | ||
| 86 | print("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO")
| |
| 87 | end | |
| 88 | ||
| 89 | function startup() | |
| 90 | ||
| 91 | term.clear() | |
| 92 | ||
| 93 | term.setCursorPos(1,1) | |
| 94 | drawloading() | |
| 95 | printLine(27,12,"O ") | |
| 96 | ||
| 97 | sleep(0.3) | |
| 98 | ||
| 99 | printLine(27,12," O ") | |
| 100 | ||
| 101 | sleep(0.3) | |
| 102 | ||
| 103 | printLine(27,12," O ") | |
| 104 | ||
| 105 | sleep(0.3) | |
| 106 | ||
| 107 | printLine(27,12,"O O") | |
| 108 | ||
| 109 | sleep(0.3) | |
| 110 | printLine(27,12," O ") | |
| 111 | sleep(0.5) | |
| 112 | ||
| 113 | end | |
| 114 | ||
| 115 | ||
| 116 | function drawScreen() | |
| 117 | w, h = term.getSize() | |
| 118 | printLine(1,1,"+-----------------------------------------------+") | |
| 119 | printLine(1,2,"| |") | |
| 120 | printLine(1,3,"| |") | |
| 121 | printLine(1,4,"| |") | |
| 122 | printLine(1,5,"| |") | |
| 123 | printLine(1,6,"| |") | |
| 124 | printLine(1,7,"| |") | |
| 125 | printLine(1,8,"| |") | |
| 126 | printLine(1,9,"| |") | |
| 127 | printLine(1,10,"| |") | |
| 128 | printLine(1,11,"| |") | |
| 129 | printLine(1,12,"| |") | |
| 130 | printLine(1,13,"| |") | |
| 131 | printLine(1,14,"| |") | |
| 132 | printLine(1,15,"| |") | |
| 133 | printLine(1,16,"| |") | |
| 134 | printLine(1,17,"+-----------------------------------------------+") | |
| 135 | printLine(3,2,"BlueTunes version "..version) | |
| 136 | printLine(w-(string.len(copyrightText)+2),16,copyrightText) | |
| 137 | end | |
| 138 | ||
| 139 | --end | |
| 140 | ||
| 141 | --programs functions | |
| 142 | ||
| 143 | function menu() | |
| 144 | while true do | |
| 145 | clear() | |
| 146 | drawScreen() | |
| 147 | menuOptions = {
| |
| 148 | ""; | |
| 149 | ""; | |
| 150 | ""; | |
| 151 | "| 1.Run Music Player"; | |
| 152 | "| 2.Settings"; | |
| 153 | "| 3.Shutdown"; | |
| 154 | "| 4.Exit"; | |
| 155 | } | |
| 156 | for i = 1,#menuOptions do | |
| 157 | printLine(1,0+i,menuOptions[i]) | |
| 158 | end | |
| 159 | printLine(3,menuSelected+3,">") | |
| 160 | event, key = os.pullEvent() | |
| 161 | if key == 200 and menuSelected > 1 then | |
| 162 | menuSelected = menuSelected-1 | |
| 163 | elseif key == 208 and menuSelected < 4 then | |
| 164 | menuSelected = menuSelected+1 | |
| 165 | elseif key == 14 then | |
| 166 | clear() | |
| 167 | break | |
| 168 | elseif key == 28 and menuSelected == 1 then | |
| 169 | music_player() | |
| 170 | elseif key == 28 and menuSelected == 2 then | |
| 171 | music_settings() | |
| 172 | elseif key == 28 and menuSelected == 3 then | |
| 173 | os.shutdown() | |
| 174 | elseif key == 28 and menuSelected == 4 then | |
| 175 | clear() | |
| 176 | break | |
| 177 | end | |
| 178 | end | |
| 179 | end | |
| 180 | ||
| 181 | function music_player() | |
| 182 | while true do | |
| 183 | clear() | |
| 184 | drawScreen() | |
| 185 | printLine(2,2," ") | |
| 186 | printLine(25,16," ") | |
| 187 | printLine(1,11,"+-----------------------------------------------+") | |
| 188 | printLine(1,3,"| OOO O O O OOOO OOOO OOOO OOO OOOO |") | |
| 189 | ||
| 190 | printLine(1,4,"| O O O O O O OO OO O O O |") | |
| 191 | ||
| 192 | printLine(1,5,"| OOOO O O O OOOO OO OO O O OOOO |") | |
| 193 | ||
| 194 | printLine(1,6,"| O O O O O O OO OO O O O |") | |
| 195 | ||
| 196 | printLine(1,7,"| OOO OOOO OOO OOOO OO OOOO OOO OOOO |") | |
| 197 | printLine((w/2)-(14/2),9,"music player") | |
| 198 | if musicPlaying == false then | |
| 199 | printLine(1,13,"| \\/\\/ +--+ |\\ +---+ ---- |") | |
| 200 | printLine(1,14,"| <()> | | | > |-->| EXIT |") | |
| 201 | printLine(1,15,"| /\\/\\ +--+ |/ +---+ ---- |") | |
| 202 | elseif musicPlaying == true then | |
| 203 | printLine(1,13,"| \\/\\/ +--+ || || +---+ ---- |") | |
| 204 | printLine(1,14,"| <()> | | || || |-->| EXIT |") | |
| 205 | printLine(1,15,"| /\\/\\ +--+ || || +---+ ---- |") | |
| 206 | end | |
| 207 | if musicSelected == 1 then | |
| 208 | printLine(4,16,"settings") | |
| 209 | printLine(5,13,"[") printLine(10,13,"]") | |
| 210 | printLine(5,14,"[") printLine(10,14,"]") | |
| 211 | printLine(5,15,"[") printLine(10,15,"]") | |
| 212 | elseif musicSelected == 2 then | |
| 213 | printLine(13,16,"stop") | |
| 214 | printLine(12,13,"[") printLine(17,13,"]") | |
| 215 | printLine(12,14,"[") printLine(17,14,"]") | |
| 216 | printLine(12,15,"[") printLine(17,15,"]") | |
| 217 | elseif musicSelected == 3 then | |
| 218 | if musicPlaying == true then | |
| 219 | printLine(21,16,"pause") | |
| 220 | else | |
| 221 | printLine(21,16,"play") | |
| 222 | end | |
| 223 | printLine(20,13,"[") printLine(26,13,"]") | |
| 224 | printLine(20,14,"[") printLine(26,14,"]") | |
| 225 | printLine(20,15,"[") printLine(26,15,"]") | |
| 226 | elseif musicSelected == 4 then | |
| 227 | printLine(30,16,"eject") | |
| 228 | printLine(29,13,"[") printLine(35,13,"]") | |
| 229 | printLine(29,14,"[") printLine(35,14,"]") | |
| 230 | printLine(29,15,"[") printLine(35,15,"]") | |
| 231 | elseif musicSelected == 5 then | |
| 232 | printLine(39,16,"exit") | |
| 233 | printLine(38,13,"[") printLine(43,13,"]") | |
| 234 | printLine(38,14,"[") printLine(43,14,"]") | |
| 235 | printLine(38,15,"[") printLine(43,15,"]") | |
| 236 | end | |
| 237 | if musicPlaying == true then | |
| 238 | f = disk.getAudioTitle(mountPath) | |
| 239 | printLine(18-(string.len(f)/2),10,"now playing: "..f) | |
| 240 | else | |
| 241 | end | |
| 242 | event, key = os.pullEvent() | |
| 243 | if key == 203 and musicSelected > 1 then | |
| 244 | musicSelected = musicSelected-1 | |
| 245 | elseif key == 205 and musicSelected < 5 then | |
| 246 | musicSelected = musicSelected+1 | |
| 247 | elseif key == 14 then | |
| 248 | disk.stopAudio(mountPath) | |
| 249 | musicPlaying = false | |
| 250 | musicDiskIn = false | |
| 251 | break | |
| 252 | elseif key == 28 and musicSelected == 1 then | |
| 253 | music_settings() | |
| 254 | elseif key == 28 and musicSelected == 2 and musicPlaying == true then | |
| 255 | disk.stopAudio() | |
| 256 | musicPlaying = false | |
| 257 | elseif key == 28 and musicSelected == 3 and musicPlaying == true then | |
| 258 | disk.stopAudio(mountPath) | |
| 259 | musicPlaying = false | |
| 260 | elseif key == 28 and musicSelected == 3 and musicPlaying == false and musicDiskIn == true then | |
| 261 | disk.playAudio(mountPath) | |
| 262 | musicPlaying = true | |
| 263 | elseif key == 28 and musicSelected == 3 and musicPlaying == false and musicDiskIn == false then | |
| 264 | printLine(2,10,"No Disk Mounted! Go to settings to mount a disk") | |
| 265 | sleep(2) | |
| 266 | elseif key == 28 and musicSelected == 4 then | |
| 267 | disk.eject("left") disk.eject("right") disk.eject("top") disk.eject("bottom") disk.eject("back") disk.eject("front")
| |
| 268 | musicPlaying = false | |
| 269 | musicDiskIn = false | |
| 270 | elseif key == 28 and musicSelected == 5 then | |
| 271 | musicPlaying = false | |
| 272 | disk.stopAudio(mountPath) | |
| 273 | musicDiskIn = false | |
| 274 | break | |
| 275 | end | |
| 276 | end | |
| 277 | end | |
| 278 | ||
| 279 | function music_settings() | |
| 280 | while true do | |
| 281 | clear() | |
| 282 | drawScreen() | |
| 283 | settingOptions = {
| |
| 284 | "| 1.Insert/Mount Disk"; | |
| 285 | "| 2.Change Mount Path-currently set to "..mountPath; | |
| 286 | "| 3.Go Back" | |
| 287 | } | |
| 288 | for i = 1,#settingOptions do | |
| 289 | printLine(1,3+i,settingOptions[i]) | |
| 290 | end | |
| 291 | printLine(3,settingSelected+3,">") | |
| 292 | printLine(3,16,settingSelected) | |
| 293 | event, key = os.pullEvent() | |
| 294 | if key == 200 and settingSelected > 1 then | |
| 295 | settingSelected = settingSelected-1 | |
| 296 | elseif key == 208 and settingSelected < 3 then | |
| 297 | settingSelected = settingSelected+1 | |
| 298 | elseif key == 14 then | |
| 299 | break | |
| 300 | elseif key == 28 and settingSelected == 1 then | |
| 301 | if disk.hasAudio(mountPath) == true then | |
| 302 | musicDiskIn = true | |
| 303 | printLine(3,8,"disk mounted...you can now play the disk") | |
| 304 | sleep(1) | |
| 305 | else | |
| 306 | printLine(3,8,"no audio found in "..mountPath) | |
| 307 | sleep(1) | |
| 308 | end | |
| 309 | elseif key == 28 and settingSelected == 2 then | |
| 310 | printLine(3,8,"Change mount path to?") | |
| 311 | term.setCursorPos(3,9) | |
| 312 | mountPathNew = read() | |
| 313 | if mountPathNew == "top" or mountPathNew == "bottom" or mountPathNew == "left" or mountPathNew == "right" or mountPathNew == "back" or mountPathNew == "front" then | |
| 314 | printLine(3,10,"New mount path accepted") | |
| 315 | mountPath = mountPathNew | |
| 316 | sleep(1) | |
| 317 | musicDiskIn = false | |
| 318 | else | |
| 319 | printLine(3,10,"Invalid side") | |
| 320 | sleep(1) | |
| 321 | end | |
| 322 | elseif key == 28 and settingSelected == 3 then | |
| 323 | break | |
| 324 | end | |
| 325 | end | |
| 326 | end | |
| 327 | ||
| 328 | --end | |
| 329 | ||
| 330 | --variables | |
| 331 | ||
| 332 | copyrightText = "[C] Bluetide Programs" | |
| 333 | version = "1.0.0" | |
| 334 | menuSelected = 1 | |
| 335 | musicPlaying = false | |
| 336 | musicSelected = 3 | |
| 337 | musicDiskIn = false | |
| 338 | settingSelected = 1 | |
| 339 | mountPath = "bottom" | |
| 340 | ||
| 341 | --end | |
| 342 | ||
| 343 | --code | |
| 344 | ||
| 345 | --startup() | |
| 346 | menu() | |
| 347 | ||
| 348 | --end |