9 posts
Posted 14 April 2012 - 10:30 AM
Im trying to get this code to open a door only when i enter password Runewar, otherwise if i enter the wrong password, to not open the door and shut down, but when i try to run it, i get this error: bios:206: [string "lock"]:4: '<eof>' expected, not entirely sure how to fix this
shell.run("clear")
print ("Enter the Password")
Password = ("Runewar")
end
if read("*") == Password then
shell.run("clear")
print ("Accepted")
redstone.setOutput("back",true)
end
else
shell.run("clear")
print("Go Away")
sleep(5)
shutdown
1111 posts
Location
Portland OR
Posted 14 April 2012 - 10:37 AM
You have an extra end, i'll comment it below..
You also have a couple other errors I'll fix and comment
Password = ("Runewar") -- moved to top so you can check against later
shell.run("clear")
print ("Enter the Password")
pass = read("*") -- capture read as a var
--end -- you dont need this
if pass == Password then -- check the output of the read vs the var Password
shell.run("clear")
print ("Accepted")
redstone.setOutput("back",true)
--end -- dont need this
else
shell.run("clear")
print("Go Away")
sleep(5)
os.shutdown() -- add ()'s and os.
end -- add this
9 posts
Posted 14 April 2012 - 10:46 AM
Okay, with your new adjustments, it works fine, thx for the help a 3rd time xD
1111 posts
Location
Portland OR
Posted 14 April 2012 - 10:57 AM
Here's a cleaned up copy without the comments, it should work. Runs fine on mine.
Password = ("Runewar") -- moved to top so you can check against later
shell.run("clear")
print ("Enter the Password")
pass = read("*")
if pass == Password then
shell.run("clear")
print ("Accepted")
redstone.setOutput("back",true)
else
shell.run("clear")
print("Go Away")
sleep(5)
os.shutdown()
end
378 posts
Location
In the TARDIS
Posted 14 April 2012 - 03:45 PM
Better use
local Password = "Runewar"
instead of
Password = "Runewar"
else it the variable Password counts for ANY Program you run that session