Posted 28 November 2013 - 07:55 AM
Hello! So today I created a password door in my startup. But now when I run it, it seems like it the program doesn't even exist! I know I didn't delete it, if you do edit startup it is right there! But when I reboot the computer, it just says CraftOS 1.5 like normal.
It has pretty long code:
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!
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!