Guest User

Untitled

a guest
Sep 17th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.16 KB | None | 0 0
  1. rednet.open("top")
  2.  
  3. local function cPrint(text)
  4. local x,y = term.getSize()
  5. local x2,y2 = term.getCursorPos()
  6. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  7. print(text)
  8. end
  9.  
  10. server = 185
  11. lock = false
  12. op[1] = "#"
  13.  
  14. while true do
  15.  term.clear()
  16.  term.setCursorPos(1,1)
  17.  
  18.  print()
  19.  cPrint("=== Nova National Bank ATM ===")
  20.  cPrint("=== Welcome! ===")
  21.  print()
  22.  cPrint("Please press the 'Enter' key to log in")
  23.  local sEvent, param = os.pullEvent("key")
  24.  if sEvent == "key" and param == 28 then
  25.   rednet.send(server, "login")
  26.   server2, message, distance = rednet.receive()
  27.   if message == "SessionLock" then
  28.    lock = true
  29.   end
  30.  end
  31.  print(lock)
  32.  while lock do
  33.    server2, message, distance = rednet.receive()
  34.   if message == "pUsername" then
  35.    cPrint("Please Enter your Username")
  36.    user = read()
  37.    rednet.send(server, user)
  38.   end
  39.  
  40.   if message == "pPassword" then
  41.    cPrint("Please enter your Password")
  42.    pass = read("*")
  43.    rednet.send(server, pass)
  44.   end
  45.  
  46.   if message == "Auth" then
  47.    cPrint("User Authenticated. Welcome " .. user .. "!")
  48.    auth = true
  49.   end
  50.  
  51.   while auth do
  52.     cPrint(" === Nova National Bank ATM === ")
  53.     cPrint("=== Welcome " .. user .. "!")
  54.     print("")
  55.     cPrint("Use the arrow keys to navigate through the menu")
  56.     print("")
  57.     cPrint( op[1] .. " Check your Balance.")
  58.     cPrint( op[2] .. "Withdraw Funds.")
  59.     cPrint( op[3] .. "Deposit Funds.")
  60.     cPrint( op[4] .. "Transfer Funds.")
  61.     cPrint( op[5] .. "Transaction History")
  62.     cPrint( op[6] .. "User Settings.")
  63.     cPrint( op[7] .. "Logout")
  64.  
  65.     local sEvent, param = os.pullEvent("key")
  66.     if sEvent == "key" and (param == 200 or param == 264  then
  67.      op[mainMen] = ""
  68.      if mainMen == 1 then
  69.       mainMen = 7
  70.      else
  71.       mainMen = mainMen - 1
  72.      end
  73.      op[mainMen] = "#"
  74.      elseif sEvent == "key" and (param == 208 or param == 265) then
  75.      op[mainMen] = ""
  76.      if mainMen == 7 then
  77.        mainMen = 1
  78.       else
  79.        mainMen = mainMen + 1
  80.       end
  81.       op[mainMen] = "#"
  82.     end
  83.  
  84.     if sEvent == "key" and (param == 28 or param == 256) then
  85.      runP(mainMen)
  86.     end
  87.   end
  88.  end
  89. end
Add Comment
Please, Sign In to add comment