Skip to content

Commit

Permalink
Update musicify.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaKnijn authored Jan 1, 2021
1 parent 4561f9c commit 7ad69d3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions musicify.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local indexURL = "https://raw.githubusercontent.com/RubenHetKonijn/computronics-songs/main/index.json?cb=" .. os.epoch("utc")
local version = 0.2
local version = 0.05

if not peripheral.find("tape_drive") then
error("Tapedrive not found")
Expand Down Expand Up @@ -30,7 +30,6 @@ local function wipe()
tape.seek(-90000)
end


local function play(songID)
print("Writing and playing " .. songID.author .. " - " .. songID.name)
wipe()
Expand All @@ -47,7 +46,6 @@ print("Writing and playing " .. songID.author .. " - " .. songID.name)
tape.play()
end


local function update()
local s = shell.getRunningProgram()
handle = http.get("https://raw.githubusercontent.com/RubenHetKonijn/musicify/main/musicify.lua")
Expand All @@ -64,7 +62,6 @@ local function update()
end
end


if version < index.latestVersion then
print("Client outdated, Updating Musicify.") -- Update check
update()
Expand All @@ -74,6 +71,7 @@ if #args <= 0 then
print("Usage: <action> [action args]")
print("Try doing musicify help for a help menu")
end

if args[1] == "help" then
print("Usage: <action> [action args]")
print("musicify help -- Displays this menu")
Expand All @@ -82,17 +80,22 @@ if args[1] == "help" then
print("musicify shuffle [from] [to] -- Starts shuffle mode in a range if specified")
print("musicify stop -- Stops playback")
print("musicify update -- Update musicify")

elseif args[1] == "update" then
print("Updating musicify.")
update()

elseif args[1] == "stop" then
print("Stopping playback")
tape.stop()

elseif args[1] == "list" then
print("Music list format: `id | author - name`")
for i in pairs(index.songs) do
print(i .. " | " .. index.songs[i].author .. " - " .. index.songs[i].name)
end
print("Use Mildly Better Shell if you want to scroll through the list")

elseif args[1] == "shuffle" then
if not args[2] then
from = 1
Expand All @@ -119,6 +122,7 @@ elseif args[1] == "shuffle" then
play(index.songs[ranNum])
sleep(index.songs[ranNum].time)
end

elseif args[1] == "volume" then
if not args[2] then
print("Please specify a volume level")
Expand All @@ -130,7 +134,12 @@ elseif args[1] == "volume" then
end
volume = tonumber(args[2]) / 100
tape.setVolume(volume)

elseif args[1] == "play" then
if not args[2] then
print("Resuming playback...")
return
end
if args[2] == "shuffle" then
print("This way of shuffling isn't supported anymore, use musicify shuffle")
return
Expand Down

0 comments on commit 7ad69d3

Please sign in to comment.