
Untitled
By: a guest on
Aug 3rd, 2012 | syntax:
None | size: 1.14 KB | hits: 13 | expires: Never
file = io.open("password","r")
pwd = file:read()
file = io.open("admin_pwd","r")
admin_pwd = file:read()
local function clear()
term.clear()
term.setCursorPos(1,1)
end
local function reDraw()
clear()
write(prompt)
end
prompt = "Password:\n>>"
reDraw()
answer = ""
run = true
while run do
event, key = os.pullEventRaw()
if event == "char" then
answer = answer .. key
prompt = prompt .. "*"
reDraw()
elseif key == 14 then -- BACKSPACE
if string.len(answer) >= 1 then
answer = string.sub(answer, 1, -2)
prompt = string.sub(prompt , 1, -2)
reDraw()
end
elseif key == 28 then -- ENTER
if answer == pwd then
clear()
write("Correct!")
redstone.setOutput("bottom",true)
sleep(3)
redstone.setOutput("bottom",false)
os.shutdown()
elseif answer == admin_pwd then
clear()
run = false
else
clear()
print("Wrong")
sleep(1)
os.reboot()
end
end
end