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

Password protect door lock

Started by robertjones6, 15 December 2012 - 06:19 PM
robertjones6 #1
Posted 15 December 2012 - 07:19 PM
This is the error message im getting:

> startup
bios:206: [string "startup"]:16: '<name>'
expected

Heres the code

os.pullEvent = os.pullEventRaw

local side="Back"
local password = "Password123"
local opentime = 3

term.clear()
term.setCursorPos(1,1)

write("Password:")
local input = read("*")
if input == password then
term.clear()
term.setCursorPos(1,1)
print("Correct")
rs.setOutput(side,true)
sleep(opentime)
rs.setOutput(side,false)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Incorrect Password")
sleep(5)
os.reboot()
end
Dlcruz129 #2
Posted 15 December 2012 - 07:23 PM
Lua is case-sensitive. Use "back", instead of " Back"

On a side note, when calling functions, remember he format is one.twoThreeFour().

Watch your shift button :P/>/>
robertjones6 #3
Posted 15 December 2012 - 07:35 PM
This is the error message im getting:

> startup
bios:206: [string "startup"]:16: '<name>'
expected

Heres the code

os.pullEvent = os.pullEventRaw

local side="Back"
local password = "Password123"
local opentime = 3

term.clear()
term.setCursorPos(1,1)

write("Password:")
local input = read("*")
if input == password then
term.clear()
term.setCursorPos(1,1)
print("Correct")
rs.setOutput(side,true)
sleep(opentime)
rs.setOutput(side,false)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Incorrect Password")
sleep(5)
os.reboot()
end

is now this


os.pullEvent = os.pullEventRaw

local side="back"
local password = "Password123"
local opentime = 3

term.clear()
term.setCursorPos(1,1)

write("Password:")
local input = read("*")
if input == password then
term.clear()
term.setCursorPos(1,1)
print("Correct")
rs.setOutput(side,true)
sleep(opentime)
rs.setOutput(side,false)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Incorrect Password")
sleep(5)
os.reboot()
end

and i am still getting that error message
Lyqyd #4
Posted 15 December 2012 - 08:05 PM
Moved to Ask a Pro.
Goof #5
Posted 15 December 2012 - 08:24 PM
I cant post any code, before i 've tested your code. So ASAP i will test, and post a full code for you..

or if yo dont want to make the whole program yourself, look into "programs" section
:D/>
theoriginalbit #6
Posted 15 December 2012 - 08:27 PM
This is the error message im getting:

> startup
bios:206: [string "startup"]:16: '<name>'
expected

Heres the code

os.pullEvent = os.pullEventRaw

local side="Back"
local password = "Password123"
local opentime = 3

term.clear()
term.setCursorPos(1,1)

write("Password:")
local input = read("*")
if input == password then
term.clear()
term.setCursorPos(1,1)
print("Correct")
rs.setOutput(side,true)
sleep(opentime)
rs.setOutput(side,false)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Incorrect Password")
sleep(5)
os.reboot()
end

is now this


os.pullEvent = os.pullEventRaw

local side="back"
local password = "Password123"
local opentime = 3

term.clear()
term.setCursorPos(1,1)

write("Password:")
local input = read("*")
if input == password then
term.clear()
term.setCursorPos(1,1)
print("Correct")
rs.setOutput(side,true)
sleep(opentime)
rs.setOutput(side,false)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Incorrect Password")
sleep(5)
os.reboot()
end

and i am still getting that error message

maybe try redstone.setOutput instead of rs.setOutput

shouldnt be an issue. but give it a try.
Goof #7
Posted 15 December 2012 - 09:59 PM
Well.. when i test it with CCEMU everything works fine… my code is:

Spoiler


local oldDog = os.pullEvent
os.pullEvent = os.pullEventRaw

local side = "back"
local password = "Password123"
local opentime = 3

term.clear()
term.setCursorPos(1,1)

write("Password:")
local input = read("*")
if input == password then
term.clear()
term.setCursorPos(1,1)
print("Correct")
rs.setOutput(side,true)
sleep(opentime)
rs.setOutput(side,false)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Incorrect Password")
sleep(5)
os.reboot()
end

os.pullEvent = oldDog
theoriginalbit #8
Posted 15 December 2012 - 10:01 PM
Well.. when i test it with CCEMU everything works fine… my code is:

Spoiler


local oldDog = os.pullEvent
os.pullEvent = os.pullEventRaw

local side = "back"
local password = "Password123"
local opentime = 3

term.clear()
term.setCursorPos(1,1)

write("Password:")
local input = read("*")
if input == password then
term.clear()
term.setCursorPos(1,1)
print("Correct")
rs.setOutput(side,true)
sleep(opentime)
rs.setOutput(side,false)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Incorrect Password")
sleep(5)
os.reboot()
end

os.pullEvent = oldDog

yeh nothing looks wrong there.
Goof #9
Posted 15 December 2012 - 10:06 PM
and it cant cause a wrong version, because all CC versions had theese function/apis…. :D/>

but if it still does not work, then reinstall CC :D/> that could be the problem.. but i dont think it is.
robertjones6 #10
Posted 16 December 2012 - 02:23 AM
with your code i get this error now


> startup
bios
:206: [string "startup"]:17: '<name>'
expected
Goof #11
Posted 16 December 2012 - 02:39 AM
are you sure, your Computercraft is installed correct? because i do not find any errors, testing it…
and, did you edit your BIOS file?

i know, i should not do this, but:

you can test my AdvLock… there are NOT any errors, when i test it.. so if it still causes errors, during my AdvLock, then your Computercraft must be configured wrong…
remiX #12
Posted 16 December 2012 - 04:12 AM
with your code i get this error now


> startup
bios
:206: [string "startup"]:17: '<name>'
expected

So you get this error from copying straight from what he has? You didn't change a thing?
dextermb #13
Posted 16 December 2012 - 04:14 AM

os.pullEvent = os.pullEventRaw
pass = "open"
print ("Enter password to open door.")
    input = read("*")
	  if input == pass then
	    shell.run("clear")
  print ("Access Granted")
    redstone.setOutput("left", true)
	  sleep(3)
	    os.reboot()
  else
    print ("Incorrect password!")
	  sleep(1)
	    shell.run("clear")
		  shell.run("open")
end
Dlcruz129 #14
Posted 16 December 2012 - 04:28 AM
You haven't overwritten any variables, right? That's the only thing I can think of that could be wrong. Break the computer and place it again.
robertjones6 #15
Posted 16 December 2012 - 06:05 PM
ok got it to work but it didnt open the door, if the redstone is at the back of the door should (side,true) (side,false) be (back,true) (back,false)?
theoriginalbit #16
Posted 16 December 2012 - 06:16 PM
yes the side parameter should be a string that is either "left" "right" "front" "back" "top" "bottom"
robertjones6 #17
Posted 17 December 2012 - 03:45 AM
so does the local side apply to the location of the redstone to the computer or the door
theoriginalbit #18
Posted 17 December 2012 - 04:08 AM
oh sorry I forgot you had a variable called side, i thought u had just got that off the API page. in that case the string stored in the side variable will apply, as long as its lowercase and one of the ones stated before.
Boss Nomad #19
Posted 17 December 2012 - 04:46 AM
Isnt the problem here:


local side="Back"

Doesnt it need to be wrote like this:


local side = "back"
robertjones6 #20
Posted 17 December 2012 - 05:23 AM
but

does the local side apply to the location of the redstone to the computer or the door
eg
redstone is behind the computer but not the door, also if you want to come and code it for me im more then happy to give you the server details