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

My Jukebox Program

Started by Raystone, 20 February 2015 - 06:27 PM
Raystone #1
Posted 20 February 2015 - 07:27 PM
Hi people. I've made a Jukebox Program. Here are the programs:

startup:

shell.run("bg startup1")

startup1:

title = disk.getAudioTitle(dSide)
m = peripheral.wrap("left")
m.setTextScale(0.5)
dSide = "drive_1"
m.setBackgroundColor(colors.black)
m.setTextColor(colors.white)
m.clear()
m.setCursorPos(1,1)
m.write("X Play")
m.setCursorPos(1,2)
m.write("X Stop")
m.setCursorPos(1,3)
m.write("X Edit")
m.setCursorPos(1,4)
m.write("X Exit")
while true do
   event, side, x, y = os.pullEvent("monitor_touch")
	 m.setCursorPos(1,6)
	 m.clearLine()
	 if x == 1 and y == 1 then
		  m.setCursorPos(1,5)
		  m.clearLine()
		  if disk.hasAudio(dSide) then
			   disk.playAudio(dSide)
			   m.setCursorPos(1,6)
			   m.write("Playing "..title)
		  else
			   m.setCursorPos(1,6)
			   m.write("No Audio")
		  end
	 elseif x == 1 and y == 2 then
		  shell.run("dj stop")
	 elseif x == 1 and y == 3 then
		  m.setCursorPos(1,3)
		  m.write("X Edit - Editing...")
		  shell.run("edit startup1")
		  shell.run("startup")
	 elseif x == 1 and y == 4 then
		  shell.run("clear")
		  disk.stopAudio("drive_0")
		  m.setCursorPos(1,6)
		  m.clearLine()
		  m.write("Not Running...")
		  shell.run("shell")
	 end
end



First it worked very well, but later I got this:
disk:3: Expected string

Here are some pictures of it:




In my Disk Drive is nothing else than a Music Disk.
I've tested it on other (new) computers, but no result…
Can anyone help me?

P.S. Sorry for my bad language. I'm not grown up with this language
Quintuple Agent #2
Posted 20 February 2015 - 07:48 PM
A problem i see is that when you call disk.getAudioTitle, dSide has not been set, so it is nil.

dSide = "drive_1"
should come before

title = disk.getAudioTitle(dSide)
Raystone #3
Posted 20 February 2015 - 07:50 PM
Thanks. It's working again! The topic can be closed now.