48 lines
1 KiB
Lua
48 lines
1 KiB
Lua
term.clear()
|
|
term.setCursorPos(1,1)
|
|
print("Chaos Gremlin Protection System")
|
|
local secret = "mrrrp"
|
|
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()
|
|
-- w = _G.write
|
|
-- p = _G.print
|
|
-- _G.write = function(text)
|
|
-- return w("meow ")
|
|
-- end
|
|
-- _G.print = function (...)
|
|
-- p("meow ")
|
|
-- end
|
|
-- b = term.blit
|
|
-- term.blit = function(text, fg, bg)
|
|
-- b("meow", fg, bg)
|
|
-- end
|