:3
This commit is contained in:
parent
491112768c
commit
68ec37f994
66 changed files with 6591 additions and 10096 deletions
36
computer/15/lock.lua
Normal file
36
computer/15/lock.lua
Normal file
|
@ -0,0 +1,36 @@
|
|||
term.clear()
|
||||
term.setCursorPos(1,1)
|
||||
print("Chaos Gremlin Protection System")
|
||||
local secret = ""
|
||||
local input = ""
|
||||
write("log in: ")
|
||||
while true do
|
||||
local event, extra = os.pullEventRaw()
|
||||
if event == "terminate" then
|
||||
print("\nnice try")
|
||||
write("log in: ")
|
||||
input = ""
|
||||
elseif event == "char" then
|
||||
input = input .. extra
|
||||
write("*")
|
||||
elseif event == "key" then
|
||||
if extra == 259 and #input > 0 then
|
||||
x, y = term.getCursorPos()
|
||||
x = x - 1
|
||||
term.setCursorPos(x, y)
|
||||
write(" ")
|
||||
term.setCursorPos(x, y)
|
||||
input = string.sub(input, 1, string.len(input) - 1)
|
||||
elseif extra == 257 then
|
||||
if input == secret then
|
||||
break
|
||||
else
|
||||
print("\nbegone, intruder\n\""..input.."\" is wrong")
|
||||
write("log in: ")
|
||||
input = ""
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
print()
|
Loading…
Add table
Add a link
Reference in a new issue