1
0
Fork 0
mirror of https://fem.mint.lgbt/m/Rhythmblock.git synced 2024-08-14 20:27:11 +00:00

new rendering system

This commit is contained in:
mint 2021-05-07 03:06:51 -04:00
parent 8e30772391
commit 39e65ab514

View file

@ -36,22 +36,31 @@ end
defaultStatus = "Rhythmblock 1.0"
invalidFormatStatus = "Not a music disc"
noDiscStatus = "No disc"
noAudioStatus = "No audio is playing"
ejectText = "Eject"
function playDisc()
term.clear()
if disk.isPresent(drive) and disk.hasAudio(drive) then -- Determines if there's a disc or not and if it's a music disc
disk.playAudio(drive)
renderStopButton()
renderEjectButton()
playing = true
status = disk.getAudioTitle(drive)
elseif disk.isPresent(drive) then -- If there's a floppy disk for example, Rhythmbox won't play it.
status = invalidFormatStatus
renderPlayButton()
renderEjectButton()
else -- If none of these checks are passed then it just means there's no disc in the drive.
status = noDiscStatus
renderPlayButton()
renderEjectButton()
end
end
function ejectDisc() -- Ejects the disc! How cool is that?
renderPlayButton()
renderEjectButton()
if playing == true then
stopDisc()
disk.eject()
@ -63,10 +72,11 @@ function ejectDisc() -- Ejects the disc! How cool is that?
end
function stopDisc() -- Stops the music
disk.stopAudio()
renderPlayButton()
playing = false
status = defaultStatus
term.clear()
renderPlayButton()
renderEjectButton()
end
function renderPlayButton() -- Renders the Play button
@ -115,6 +125,7 @@ while true do
playDisc()
end
elseif eventData[2] == 1 and eventData[3] >= centerWidth - 2 and eventData[4] >= centerHeight + 4 and eventData[3] <= centerWidth + 2 and eventData[4] <= centerHeight + 4 then
term.clear()
ejectDisc()
end
elseif event == "monitor_touch" then
@ -125,6 +136,7 @@ while true do
playDisc()
end
elseif eventData[3] >= centerWidth - 2 and eventData[4] >= centerHeight + 4 and eventData[3] <= centerWidth + 2 and eventData[4] <= centerHeight + 4 then
term.clear()
ejectDisc()
end
elseif event == "key_up" then
@ -135,6 +147,8 @@ while true do
else
playDisc()
end
if name == "e" then
ejectDisc()
elseif name == "q" then
term.clear()
term.setCursorPos(1, 1)