4 posts
Posted 29 July 2012 - 01:18 AM
Ok so I need a pros help here!
I was watching this tutorial on how to make a keycard lock
http://www.youtube.com/watch?v=KfDDoTh2s2oand i followed everything it said, wrote the massive code on a file called keycard on my computer, i made an access file on a floppy disk with the password, i used redpower to wire the computer up to the door from the left side like he said, but he never told me how to run it properly, do i need to run keycard for my computer to turn into the keycard lock? cause when i try and run keycard it just says
[left]bios:206: [string "keycard"]:27: ')' expected[/left][left]I really hope someone can help me cause i spent a while writing all that down and stuff and i really need this to work![/left]
3790 posts
Location
Lincoln, Nebraska
Posted 29 July 2012 - 01:26 AM
If you could post a copy of what code you do have, it would be great. If you had to write it down, you can just use copy/paste from the disk file in your minecraft folder. Just go to .minecraft/computercraft/, and find the number of your disk, (Edit: you need the computer number. just type id into your computer, and that should show you what number computer it is, and you can extract the file from there) and your keycard program should be in there. Open it up with Notepad, and copy/paste the code you have here. It sounds like just one character was left out of the code, so might be simple as that to fix.
Edited on 28 July 2012 - 11:30 PM
4 posts
Posted 29 July 2012 - 02:02 AM
If you could post a copy of what code you do have, it would be great. If you had to write it down, you can just use copy/paste from the disk file in your minecraft folder. Just go to .minecraft/computercraft/, and find the number of your disk, (Edit: you need the computer number. just type id into your computer, and that should show you what number computer it is, and you can extract the file from there) and your keycard program should be in there. Open it up with Notepad, and copy/paste the code you have here. It sounds like just one character was left out of the code, so might be simple as that to fix.
I cant seem to find the floppy disk anymore, but if you check the video desc, it has the code, also the first part of the video shows the way the code is write. not sure if that helps?
3790 posts
Location
Lincoln, Nebraska
Posted 29 July 2012 - 04:05 AM
What I mean, is it may be that you left out a character when copying it over, and I just wanted to know if your code matches with his.
He has his code like this:
password = "password"
debug_char = "0"
term.clear()
function mainLoop()
while(true) do
event, driveSide = os.pullEventRaw()
if(event=="disk" and driveSide) then
path = disk.getMountPath(driveSide)
if(path) then
path = path.."/access"
file = fs.exists(path) and io.open(path, "r") or nil
end
disk.eject(driveSide)
if(file and file:read()==password) then
rs.setOutput("left", true)
sleep(3)
rs.setOutput("left", false)
end
if(file) then file:close() file = nil end
elseif(debug_char and event=="char" and driveSide==debug_char) then return("break") end
end
end
rs.setOutput("left", false)
sfile = io.open("/startup", "w")
sfile:write('shell.run("keycard")')
sfile:close()
repeat
ok, err, val = pcall(mainLoop)
if(not ok and err) then
if(err=="Terminated") then print ("Access denied.")
else
print(err)
end
end
until(ok and err=="break")
I have no problems with it.