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

Code door problem

Started by candycool1234, 17 May 2013 - 01:22 PM
candycool1234 #1
Posted 17 May 2013 - 03:22 PM
I made this code but there's a error if needed I can post the error but it will take a second thank you for your time.

print("Welcome to the hovel")
correctuser = "Jacob"
correctuser2 = "fuzzy"
correctuser3 = "dg"
write("Username:")
user = read()
if user == ("correctuser") then
print("Welcome Creator")
elseif user == (correctuser2) then
print("Welocme fuzzy...")
elseif user == (correctuser3) then
print("Welocme DG :D/>")
correctpass = "fuckoff"
write("Password:")
pass = read("*")
elseif pass == (correctpass) then
rs.setOutput("right",true)
sleep(3)
os.shutdown()
else
print("incorrect leave the hovel intruder!")
sleep(4)
os.shutdown()
candycool1234 #2
Posted 17 May 2013 - 03:44 PM
can anyone help me with this?
H4X0RZ #3
Posted 17 May 2013 - 03:53 PM
The error is here

 if user == ("correctuser") then

It have to be

if user ==(correctuser) then

a little mprovement

local users = {
["Name1"] = true,
["Name2"] = true
}

write("Username:")
local usr = read()

if users[usr] then
--Do something
else
print("You aren't on the list")
end
candycool1234 #4
Posted 17 May 2013 - 03:58 PM
yea that might help but this code is to protect my hovel and I need a user and pass I wish I new more about lua and I am trying to improve my understanding in it so thank you if u could explain what the new codes do and mean that would be great

*knew im sorry
candycool1234 #5
Posted 17 May 2013 - 04:14 PM
new improved code is here http://www.pastebin.com/gdc1pc9Z
candycool1234 #6
Posted 17 May 2013 - 04:16 PM
one problem is it skips past the pass part after the user and goes strait to pass