Today I bring to you a Computer lock, the original idea was not mine.
To be fair I'll reference the original thread from where I got the idea, or to be more clear what I improved on. Click Here.
Alright so now that that's out of the way, basically I just started learning code syntax and I've had a close friend take me step by step through basic syntax and variable scopes, etc.
I've been messing around with it and cleaning it up, and I do believe I severely improved on the code, or atleast made it look much cleaner.
So give me your critique or any suggestions, here we go:
FORUM MADE THE SPACING LOOK WEIRD CLICK HERE FOR AN EASIER TO READ VERSION.
function clear()
term.clear()
term.setCursorPos(1,1)
end
function lock()
local PASSWORD = "PASSWORD GOES HERE"
local temp = os.pullEvent
local function dkeys(swap)
disable = {
[0] = function() os.pullEvent = temp end,
[1] = function() os.pullEvent = os.pullEventRaw end
}
disable[swap]()
end
clear()
dkeys(1)
print("Enter password:")
write("> ")
local input = read()
if input == PASSWORD then
clear()
dkeys(0)
print("Access granted!")
textutils.slowPrint("Loading...")
sleep(1)
clear()
print("WELCOME MESSAGE")
else
clear()
print("Access denied!")
textutils.slowPrint("Rebooting...")
sleep(1)
os.reboot()
end
end
lock()