Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ATMApi.lua")
- rednet.open("top")
- os.pullEvent = os.pullEventRaw
- local w,h = term.getSize()
- function printCentered( y,s )
- local x = math.floor((w - string.len(s)) / 2)
- term.setCursorPos(x,y)
- term.clearLine()
- term.write(s)
- end
- password = ""
- display = ""
- nOption = ""
- function menu(pass)
- term.clear()
- printCentered( math.floor(h/2) - 3, "Enter password")
- printCentered( math.floor(h/2) - 1, pass)
- end
- menu(display)
- while true do
- local event, key = os.pullEvent("key")
- if key == keys.one then
- password = password .. "1"
- display = display .. "*"
- menu(display)
- elseif key == keys.two then
- password = password .. "2"
- display = display .. "*"
- menu(display)
- elseif key == keys.three then
- password = password .. "3"
- display = display .. "*"
- menu(display)
- elseif key == keys.four then
- password = password .. "4"
- display = display .. "*"
- menu(display)
- elseif key == keys.five then
- password = password .. "5"
- display = display .. "*"
- menu(display)
- elseif key == keys.six then
- password = password .. "6"
- display = display .. "*"
- menu(display)
- elseif key == keys.seven then
- password = password .. "7"
- display = display .. "*"
- menu(display)
- elseif key == keys.eight then
- password = password .. "8"
- display = display .. "*"
- menu(display)
- elseif key == keys.nine then
- password = password .. "9"
- display = display .. "*"
- menu(display)
- elseif key == keys.zero then
- password = password .. "0"
- display = display .. "*"
- menu(display)
- elseif key == keys.backspace then
- password = password:sub(1, #password - 1)
- display = display:sub(1, #display - 1)
- menu(display)
- elseif key == keys.enter then
- if ATMApi.cardIn() == true then
- message = ATMApi.getCardData()
- if message == nil then print("no") end
- if message ~= nil then
- --print(message.pass, password)
- if tostring(message.pass) == tostring(password) then
- nOption = "true_pass"
- break
- end
- end
- else shell.run("main")
- end
- end
- --if ATMApi.cardIn() == true then break end
- end
- if nOption == "true_pass" then shell.run("main_menu")
- else shell.run("main") end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement