It has pretty long code:
function clear()
term.clear()
term.setCursorPos(1,1)
end
function menu()
function menu()
term.clear()
term.setCursorPos(1,1)
print(" ")
print("Door Admin Menu.")
print(" ")
print(" Press A for new password.")
print(" ")
print(" Press S for new admin password.")
print(" ")
print(" Press D for a new side")
print(" ")
print(" Press F to exit.")
end
function a()
clear()
h = fs.open("pass", "r")
local oldPass = h.readAll()
h.close()
print("Old password:")
local oldInput = read()
if oldInput == oldPass then
print("New password:")
local newPass = read()
h = fs.open("pass", "w")
h.write(newPass)
h.close()
sleep(1)
menu()
else
print("Incorrect.")
sleep(1)
menu()
end
end
function s()
clear()
h = fs.open("admin", "r")
oldPass = h.readAll()
print("Old admin pass:")
local oldInput = read()
if oldInput == oldPass then
print("New admin pass:")
local newPass = read()
h = fs.open("admin", "w")
h.write(newPass)
h.close()
menu()
else
print("Incorrect.")
sleep(1)
menu()
end
end
function d()
clear()
print("New side:")
local newSide = read()
h = fs.open("side", "w")
h.write(newSide)
h.close()
menu()
end
function f()
clear()
os.reboot()
end
clear()
print("SafeCo Door Lock.")
print("Please input password:")
f = fs.open("pass", "r")
local rPass = f.readAll()
f.close()
local f = fs.open("admin", "r")
local aPass = f.readAll()
f.close()
local pass = read("*")
if pass == rPass then
f = fs.open("side", "r")
local side = f.readAll()
f.close()
sleep(1)
print("Correct!")
rs.setOutput(side, true)
sleep(3)
rs.setOutput(side, false)
elseif pass == aPass then
sleep(1)
print("Welcome, admin.")
menu()
ev,p1 = os.pullEvent("char")
if p1 == "a" then
a()
elseif p1 == "s" then
s()
elseif p1 == "d" then
d()
elseif p1 == "f" then
f()
end
end
end
Any problems with this?By the way, I would also like to congratulate everyone who posted on my 'How did you learn lua?' topic.
Everyone really helped! Thanks!
But back to the subject.
What happened?
Thank you!












