14 posts
Location
Canada
Posted 29 February 2012 - 08:08 AM
I'm kind of new to lua, although i used to play ROBLOX (lol, i quit that game long ago it was so shitty) but i have coded some javascript so i understand the concept. I'm trying to make a lock system that asks you for a password the tells you if its right or not. if its right it prints welcome, if its wrong it shuts down the system. I came up with this
Spoiler
term.clear()
print ("Welcome To Aperture Labratories")
write ("Enter Access Code:")
passcode = read()
if passcode == "12345" then
print ("Correct, Welcome!")
else print ("Incorrect!") then
term.clear
term.setCursorPos(1,1)
print ("Security Enabled")
os.shutdown
end
end but it doesnt work :o/>/> HELP! thanks!
[right]-Lord_darkis[/right]
496 posts
Location
Harlem, NY
Posted 29 February 2012 - 08:21 AM
term.clear()
print ("Welcome To Aperture Labratories")
write ("Enter Access Code:")
passcode = read()
if passcode == "12345" then
print ("Correct, Welcome!")
else print ("Incorrect!") then
term.clear()
term.setCursorPos(1,1)
print ("Security Enabled")
os.shutdown
end
Fixed code above.
Problem 1. Line 10 you had term.clear, all functions need () at the end. Such as you did on line 1, ironically.
Problem 2: You had an unnecessary "end" on line 15
14 posts
Location
Canada
Posted 29 February 2012 - 08:47 AM
term.clear()
print ("Welcome To Aperture Labratories")
write ("Enter Access Code:")
passcode = read()
if passcode == "12345" then
print ("Correct, Welcome!")
else print ("Incorrect!") then
term.clear()
term.setCursorPos(1,1)
print ("Security Enabled")
os.shutdown
end
Fixed code above.
Problem 1. Line 10 you had term.clear, all functions need () at the end. Such as you did on line 1, ironically.
Problem 2: You had an unnecessary "end" on line 15
Tried your changes still get the same error
error: bios:206: [string "startup"] :9: unxepected symbol
I assume that means something was in there thats not supposed to.
36 posts
Posted 29 February 2012 - 09:18 AM
term.clear()
print ("Welcome To Aperture Labratories")
write ("Enter Access Code:")
passcode = read()
if passcode == "12345" then
print ("Correct, Welcome!")
else print ("Incorrect!") then
term.clear()
term.setCursorPos(1,1)
print ("Security Enabled")
os.shutdown
end
Fixed code above.
Problem 1. Line 10 you had term.clear, all functions need () at the end. Such as you did on line 1, ironically.
Problem 2: You had an unnecessary "end" on line 15
Tried your changes still get the same error
error: bios:206: [string "startup"] :9: unxepected symbol
I assume that means something was in there thats not supposed to.
At line 7 you're using a then after the else. This is not needed since it isn't an if or an elseif, just an else. The correct code would probably be:
term.clear()
print ("Welcome To Aperture Labratories")
write ("Enter Access Code:")
passcode = read()
if passcode == "12345" then
print ("Correct, Welcome!")
else
print ("Incorrect!")
term.clear()
term.setCursorPos(1,1)
print ("Security Enabled")
sleep(2) --I added this sleep because otherwise you would not even see the prints, it would immediatly shutdown.
os.shutdown
end
Hope this fixes the problem?
-Chub1337
14 posts
Location
Canada
Posted 29 February 2012 - 09:44 AM
term.clear()
print ("Welcome To Aperture Labratories")
write ("Enter Access Code:")
passcode = read()
if passcode == "12345" then
print ("Correct, Welcome!")
else print ("Incorrect!") then
term.clear()
term.setCursorPos(1,1)
print ("Security Enabled")
os.shutdown
end
Fixed code above.
Problem 1. Line 10 you had term.clear, all functions need () at the end. Such as you did on line 1, ironically.
Problem 2: You had an unnecessary "end" on line 15
Tried your changes still get the same error
error: bios:206: [string "startup"] :9: unxepected symbol
I assume that means something was in there thats not supposed to.
At line 7 you're using a then after the else. This is not needed since it isn't an if or an elseif, just an else. The correct code would probably be:
term.clear()
print ("Welcome To Aperture Labratories")
write ("Enter Access Code:")
passcode = read()
if passcode == "12345" then
print ("Correct, Welcome!")
else
print ("Incorrect!")
term.clear()
term.setCursorPos(1,1)
print ("Security Enabled")
sleep(2) --I added this sleep because otherwise you would not even see the prints, it would immediatly shutdown.
os.shutdown
end
Hope this fixes the problem?
-Chub1337
ok so i did that it was right but know tits telling me that somethings wrong with the last line (14) its say '=' expected
36 posts
Posted 29 February 2012 - 09:48 AM
Oh, my bad, didn't see that one, os.shutdown has to be os.shutdown(), it's a function :o/>/>
-Chub1337
14 posts
Location
Canada
Posted 29 February 2012 - 09:51 AM
Oh, my bad, didn't see that one, os.shutdown has to be os.shutdown(), it's a function :o/>/>
-Chub1337
woops forgot that oh and thx so much!!!! Diamonds to you!
36 posts
Posted 29 February 2012 - 09:56 AM
Oh, my bad, didn't see that one, os.shutdown has to be os.shutdown(), it's a function :o/>/>
-Chub1337
woops forgot that oh and thx so much!!!! Diamonds to you!
You're welcome :)/>/>
-Chub1337
496 posts
Location
Harlem, NY
Posted 29 February 2012 - 10:48 AM
Fixed code above.
Problem 1. Line 10 you had term.clear, all functions need () at the end. Such as you did on line 1, ironically.
Problem 2: You had an unnecessary "end" on line 15
36 posts
Posted 29 February 2012 - 06:05 PM
Fixed code above.
Problem 1. Line 10 you had term.clear, all functions need () at the end. Such as you did on line 1, ironically.
Problem 2: You had an unnecessary "end" on line 15
Haha, guess you overlooked that one aswell Fuzzy :unsure:/>/>/>