Posted 30 August 2012 - 05:15 PM
hi there! ;D , this is a complicated terminal lock program I made called Dark Lock with an easy to use setup and install so you can install it on all your ingame computers.
If the password is wrong (default 5 times) the computer will be locked out for a number of seconds (defualt 30)
You can change your password with the "setup" program.
In a bid to make things look nicer, I have added a few functions to center text on the screen :)/>/>/>
All these scripts were written by me, if you want to use / edit them please give me credit!
How to use
From floppy disk:
First make a file called "startup" on the floppy disk. This is the installer.
Next make a file called lock. This file will be renamed by the installer when copied to the computer.
Lastly make a file called setup.
now on your floppy disk you should have the following files
startup
lock
setup
if you wish to put the program directly on the computer then just put setup and rename lock to startup directly into the computers folder like so:
lock -> startup
setup
Please report any bugs / errors you find :)/>/>/>
If the password is wrong (default 5 times) the computer will be locked out for a number of seconds (defualt 30)
You can change your password with the "setup" program.
In a bid to make things look nicer, I have added a few functions to center text on the screen :)/>/>/>
All these scripts were written by me, if you want to use / edit them please give me credit!
How to use
From floppy disk:
First make a file called "startup" on the floppy disk. This is the installer.
Spoiler
print("---------------Welcome!----------------")
print("---------Dark lock installer!----------")
print("---------------------------------------")
print("This will install Dark Lock 1.4 to your")
print("---------Minecraft Computer------------")
print("")
print(" 1. Install Dark lock")
print(" 2. Exit ")
print("---------------------------------------")
print(" Warning! Dark lock will overide ")
print(" Your default startup program")
print("")
write("type a number then press enter: ")
user=io.read()
function makeprogram()
term.clear() term.setCursorPos(1,1)
print("Looking for old startup file...")
sleep(1)
if fs.exists("startup") == true then
shell.run("rm", "startup")
print("Startup file found, deleting...")
sleep(1)
end
if fs.exists("setup") == true then
shell.run("rm", "setup")
end
if fs.exists("lock/conf") == true then
shell.run("rm", "lock/conf")
end
if fs.exists("lock/attempt") == true then
shell.run("rm", "lock/attempt")
end
sleep(1)
print("Making new directory...")
shell.run("mkdir", "lock")
sleep(2)
print("Copying Files...")
print("")
sleep(1)
file = io.open("lock/attempt","w")
file:write("")
file:close()
file = io.open("lock/conf","w")
file:write("")
file:close()
shell.run("cp", "disk/lock", "/startup")
if fs.exists("startup") == true then
print ("Startup copy... Success")
else
print ("Startup copy... Failed")
end
sleep(1)
print("")
shell.run("cp", "disk/setup", "/")
if fs.exists("setup") == true then
print ("setup copy... Success")
else
print ("setup copy... Failed")
end
sleep(1)
print("")
print("Install completed")
sleep(1)
print("")
print("now running setup")
sleep(2)
shell.run("setup")
end
--running program
if user=="1" then
term.clear() term.setCursorPos(1,1)
print("Running install...")
sleep(2)
makeprogram()
end
if not(user=="1") then
term.clear() term.setCursorPos(1,1)
print("Exiting...")
sleep(2)
term.clear() term.setCursorPos(1,1)
shell.run("startup")
end
Next make a file called lock. This file will be renamed by the installer when copied to the computer.
Spoiler
--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()
Lastly make a file called setup.
Spoiler
term.clear() term.setCursorPos(1,1)
print("Welcome to Dark Lock setup")
print("Press Enter to continue...")
io.read()
file = io.open("lock/conf","w")
term.clear() term.setCursorPos(1,1)
write("Type your new password: ")
pass=read("*")
term.clear() term.setCursorPos(1,1)
print("Type number of attempts before lockout: ")
print("default: 5")
write(": ")
attempts=io.read()
if (attempts == "") then
attempts = 5
end
term.clear() term.setCursorPos(1,1)
print("Type the new lockout duration: ")
print("defualt: 30")
write(": ")
lockout=io.read()
if (lockout == "") then
lockout = 30
end
file:write("pass = "..[["]]..pass..[["]].." numberofattempts="..attempts.." lockoutperiod="..lockout)
file:close()
term.clear() term.setCursorPos(1,1)
print("Setup complete!")
sleep(1)
print("rebooting...")
sleep(2)
shell.run("startup")
now on your floppy disk you should have the following files
startup
lock
setup
if you wish to put the program directly on the computer then just put setup and rename lock to startup directly into the computers folder like so:
lock -> startup
setup
Please report any bugs / errors you find :)/>/>/>