Rhythmblock/rhythmblock.lua

59 lines
1.2 KiB
Lua
Raw Normal View History

2021-05-06 14:22:19 +00:00
accentColor = colors.gray
buttonColor = colors.lightGray
backgroundColor = colors.black
width, height = term.getSize()
centerWidth = math.round(width / 2)
centerHeight = math.round(width / 2)
peripherals = peripheral.getNames()
playing = false
if #peripherals < 0 then
print "No drive"
else
driveCount = 0
for n = 1, #peripherals do
local driveCheck = peripherals[n]
if peripheral.getType(driveCheck) == "drive" then
drive = driveCheck
driveCount = driveCount + 1
end
end
if driveCount > 1 then
print("Too many disk drives. Specify where the disk drive is with the argument -d")
os.exit()
end
end
status = ""
function playDisc()
if disk.isPresent(drive) and disk.hasAudio(drive) then
disk.playAudio(drive)
status = disk.getAudioTitle(drive)
playing = true
elseif disk.isPresent(drive) then
print "Not a music disc"
else
print "No disc"
end
end
function ejectDisc()
disk.eject()
end
function stopDisc()
if playing == true then
disk.stopAudio()
status = "Rhythmblock 0.0.1a"
else
status = "No disc is playing"
end
end
function renderPlayButton()
paintutils.drawFilledBox(centerWidth - 5, centerHeight - 5, centerWidth + 5, centerHeight + 5 accentColor)
end