This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
BigSHinyToys's profile picture

CD stacking turtle

Started by BigSHinyToys, 28 August 2012 - 07:03 AM
BigSHinyToys #1
Posted 28 August 2012 - 09:03 AM
CD stacker is a simple little program that allows you to play CD's easily using a turtle and disk drive.

Set up like this

Spoiler

Then run this code
Spoiler

--[[
		CD stacker by BigSHinyToys
		I release this script Public Domain and Open Source.
		do what ever you what to it.
]]--
term.clear()
term.setCursorPos(1,1)
print("checking System")
local verCD = 0.2
local TrackList = {}
local playing = 0
if turtle and peripheral.isPresent("bottom") and peripheral.getType("bottom") == "drive" then
	print("Disk Drive Found")
	for i = 1,16 do
		turtle.select(i)
		turtle.dropDown()
		if disk.hasAudio("bottom") then
			table.insert(TrackList,{name = disk.getAudioTitle("bottom"),slot = i})
		end
		turtle.suckDown()
	end
	print("Found "..#TrackList.." tracks")
	while true do
		term.clear()
		term.setCursorPos(1,1)
		print("Tracks are")
		for i = 1,#TrackList do
			local mark = " ) "
			if i == playing then
				mark = " =>"
			end
			print(i..mark..TrackList[i].name)
		end
		print([[select "track Number", "stop" or "exit"]])
		local slection = read()
		local track = tonumber(slection)
		if slection == "stop" then
			disk.stopAudio("bottom")
			turtle.suckDown()
			playing = 0
		elseif slection == "exit" then
			disk.stopAudio("bottom")
			turtle.suckDown()
			playing = 0
			break
		elseif track ~= nil and track > 0 and track <= #TrackList then
			disk.stopAudio("bottom")
			turtle.suckDown()
			turtle.select(TrackList[track].slot)
			turtle.dropDown()
			disk.playAudio("bottom")
			playing = track
		end
	end
	term.clear()
	term.setCursorPos(1,1)
	print("Thank you for using CD stack")
else
	if turtle then
		print("please place a disk under the turtle")
	else
		print("please use a turtle and disk drive")
	end
end

To play a track just type its number and hit enter
FuzzyPurp #2
Posted 28 August 2012 - 09:30 AM
I like this