9 posts
Posted 16 April 2013 - 09:51 AM
Hi, im kind of new to ComputerCraft, but understand most of the basics.
Right now im trying to make a disk play by the DJ command, when stading on a pressure plate next to a computer, but i cant seem to work it out.
I tried to code it myself, but im not sure how to make it work.
local side = "right"
while true do
term.clear()
term.setCursorPos(1,1)
write("Waiting...")
local input = redstone.getInput("right")
if input then
shell.run("dj", "play", "left")
term.clear()
term.setCursorPos(1,1)
print("Playing...")
sleep(5)
end
end
Would enjoy some help, thanks.
103 posts
Location
Eclipse
Posted 16 April 2013 - 10:14 AM
First when you declared the variable
side="right"
You never use it. This is not your problem, but it is unnecessary. Is there a noteblock you are trying to make a sound? Do you have a disk drive to your left? DJ needs a music disk to be loaded
169 posts
Posted 16 April 2013 - 10:24 AM
Well, there are several things wrong with it. But I don't see any problems that would stop it from working, except for that infinite loop. Try this instead:
while true do
term.clear()
term.setCursorPos(1,1)
print("Waiting...")
os.pullEvent("redstone")
shell.run("dj", "play", "left")
term.clear()
term.setCursorPos(1,1)
print("Playing...")
sleep(5)
end
That will wait until a redstone signal changes, start playing the disk, wait five seconds, then wait for the redstone signal to change again.
9 posts
Posted 16 April 2013 - 10:25 AM
First when you declared the variable
side="right"
You never use it. This is not your problem, but it is unnecessary. Is there a noteblock you are trying to make a sound? Do you have a disk drive to your left? DJ needs a music disk to be loaded
Yeah, I have a disk drive on the left side which I am trying to activate by stepping on a pressure plate. Im just kind of clueless when it comes to coding.
Well, there are several things wrong with it. But I don't see any problems that would stop it from working, except for that infinite loop. Try this instead:
while true do
term.clear()
term.setCursorPos(1,1)
print("Waiting...")
os.pullEvent("redstone")
shell.run("dj", "play", "left")
term.clear()
term.setCursorPos(1,1)
print("Playing...")
sleep(5)
end
That will wait until a redstone signal changes, start playing the disk, wait five seconds, then wait for the redstone signal to change again.
Much better! That worked! Thanks :)/>
103 posts
Location
Eclipse
Posted 16 April 2013 - 10:30 AM
Here is a video:
Spoiler
[media]http://youtu.be/39i-xJzBaHU[/media] Done processing!
Edited on 16 April 2013 - 08:39 AM