Posted 24 December 2012 - 11:08 AM
Well basically I wanted to make a program that asks you a password… but then I thought: "Hey that's way to boring for me and my friends!" So I inserted a little riddle to decide who is worthy enough to enter. I also added a little part in the beginning, so that if you are an admin (I chose to name it Benjamin after me) then you can chose to login and skip the riddle. The code will be in the post for I am sure you people can make it a lot easier!
term.clear()
term.setCursorPos(1, 1)
print("Are you a guest? Press 1. Are you Benjamin? Press 3 to Login.")
visit = io.read()
if visit == "1" then
term.clear()
term.setCursorPos(1, 1)
correctpass = "time"
print("This thing all things devours:")
print("Birds, beasts, trees, flowers;")
print("Gnaws iron, bites steel;")
print("Grinds hard stones to meal;")
print("Slays king, ruins town,")
print("And beats high mountain down.")
print("What am I?")
pass = io.read()
term.clear()
term.setCursorPos(1, 1)
if pass == (correctpass) then
write("You are worthy, you may pass.")
redstone.setOutput("right",true)
sleep(3)
os.shutdown()
else
write("You are not worthy to enter. BEGONE!")
sleep(2)
os.shutdown()
end
else
if visit == "3" then
term.clear()
term.setCursorPos(1, 1)
print("Username: ")
Username = io.read()
print("Password: ")
Password = io.read()
if Username == "Benjamin" and Password == "test" then
term.clear()
term.setCursorPos(1, 1)
print("Welcome admin.")
redstone.setOutput("right",true)
sleep(6)
os.shutdown()
else
shell.run('startup')
end
else
end
end