Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Title: Dark lock 1.4
- --Version: Ver. 1.4
- --Author: Darkrising (minecraft alias djhannz)
- --Platform: ComputerCraft LUA Virtual Machine
- --Notes: lock program with lockout period
- --config
- --numbers are in seconds
- dofile("lock/attempt")
- dofile("lock/conf")
- counter=0
- attemptcounter=0
- i=0
- yes=0
- function timercheck()
- if (istimergoing == 1) then
- term.clear() term.setCursorPos(1,1)
- print("You attempted to restart the computer!")
- print("")
- print("Restarting Countdown.")
- pcall(sleep,3)
- countdown()
- end
- end
- function beforelock()
- timercheck()
- if counter==numberofattempts then
- pcall(countdown)
- end
- if not (counter == numberofattempts) then
- lock()
- end
- end
- function lock()
- repeat
- status, user=pcall(read,"*")
- if user == pass then
- term.clear() term.setCursorPos(1,1)
- screenwrite("Password Correct",1)
- pcall(sleep,1)
- term.clear() term.setCursorPos(1,1)
- shell.run("shell")
- yes=1
- end
- if not (user == pass) then
- term.clear() term.setCursorPos(1,1)
- attemptcounter=attemptcounter+1
- counter=counter+1
- screenwrite("Incorrect Attempts: "..attemptcounter,1)
- lineacross("-",2)
- screenwrite("Wrong Password",3)
- print("")
- write("Password: ")
- i=i+1
- beforelock()
- end
- until yes==1
- end
- function countdown()
- cou=lockoutperiod
- repeat
- pcall(sleep,1)
- term.clear() term.setCursorPos(1,1)
- cou=cou-1
- screenwrite("Too many wrong attempts",1)
- screenwrite("Please wait "..cou.." Seconds before trying again",2)
- file = io.open("lock/attempt","w")
- file:write("istimergoing = ".. 1)
- file:close()
- until cou==0
- attemptcounter=0
- file = io.open("lock/attempt","w")
- file:write("istimergoing = ".. 0)
- file:close()
- istimergoing = 0
- counter=0
- cou=lockoutperiod
- term.clear() term.setCursorPos(1,1)
- screenwrite("Incorrect Attempts: "..attemptcounter,1)
- lineacross("-",2)
- screenwrite("Wrong Password",3)
- print("")
- write("Password: ")
- beforelock()
- end
- function screenwrite(text, line)
- x,y = term.getSize()
- l = string.len(text)
- x = (x/2 - l/2)
- term.setCursorPos(x,line)
- term.write(text)
- cx, cy = term.getCursorPos()
- term.setCursorPos(1, cy+1)
- end
- function lineacross(text, line)
- x,y = term.getSize()
- term.setCursorPos(x,line)
- for i=1,x do
- term.setCursorPos(i,line)
- term.write(text)
- end
- cx, cy = term.getCursorPos()
- term.setCursorPos(1, cy+1)
- end
- term.clear() term.setCursorPos(1,1)
- lineacross("-",1)
- screenwrite("Welcome!",2)
- screenwrite("This computer is running Dark lock 1.4",3)
- lineacross("-",4)
- write("Password: ")
- beforelock()
Add Comment
Please, Sign In to add comment