trainworld_computercraft/computer/15/lock.lua
2025-07-03 01:23:46 +02:00

36 lines
No EOL
829 B
Lua

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()