Redxone

[Flyte Bank] ATM

Nov 26th, 2015
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.00 KB | None | 0 0
  1. os.loadAPI("css")
  2.  
  3. local user = "Debug"
  4. local w,h = css.width, css.height
  5. local balance = 0
  6. local loggedin = true
  7. local options = {
  8.     "Deposit ",
  9.     "Withdraw",
  10.     "Transfer",
  11.     " Logout ",
  12. }
  13. menu = css.createMenu(
  14.   math.floor((w/2))-4, math.floor((h/2)) + 2,
  15.   colors.orange,
  16.   colors.red,
  17.   0.5,
  18.   colors.red,
  19.   colors.white,
  20.   options
  21.  
  22. )
  23.  
  24. function screen()
  25.     css.sbc(colors.white)
  26.     css.clear()
  27.     css.box(1,1,css.width, (css.height/2) - 1, colors.red)
  28. end
  29.  
  30. function deposit()
  31.   screen()
  32.   css.stc(colors.white)
  33.   css.cprint("DEPOSIT",2)
  34.   css.cprint("Please enter the ammount of money",3)
  35.   css.cprint("you would like to deposit into ",4)
  36.   css.cprint("Account: " .. user,6)
  37.   css.stc(colors.red)
  38.   css.sbc(colors.white)
  39.   css.cprint("Input ammount of money below.",12)
  40.   css.cprint("Current balance: " .. balance, 16)
  41.   css.sbc(colors.gray)
  42.   css.scp((w/2) - 10, 14)
  43.   write(string.rep(" ",20))
  44.   css.stc(colors.white)
  45.   css.scp((w/2) - 10, 14)
  46.   money = read()
  47.  
  48.   --]] do money check logic here [[--
  49.   atm()
  50.  
  51. end
  52.  
  53. function withdraw()
  54.   screen()
  55.   css.stc(colors.white)
  56.   css.cprint("WITHDRAW",2)
  57.   css.cprint("Please enter the ammount of money",3)
  58.   css.cprint("you would like to withdraw from ",4)
  59.   css.cprint("Account: " .. user,6)
  60.   css.stc(colors.red)
  61.   css.sbc(colors.white)
  62.   css.cprint("Input ammount of money below.",12)
  63.   css.cprint("Current balance: " .. balance, 16)
  64.   css.sbc(colors.gray)
  65.   css.scp((w/2) - 10, 14)
  66.   write(string.rep(" ",20))
  67.   css.stc(colors.white)
  68.   css.scp((w/2) - 10, 14)
  69.   money = read()
  70.  
  71.   --]] do money check logic here [[--
  72.   atm()
  73.  
  74. end
  75.  
  76. function transfer()
  77.   screen()
  78.   css.stc(colors.white)
  79.   css.cprint("TRANFER",2)
  80.   css.cprint("Please enter the ammount of money",3)
  81.   css.cprint("and the recipient account. ",4)
  82.   css.cprint("From Account: " .. user,6)
  83.   css.stc(colors.red)
  84.   css.sbc(colors.white)
  85.   css.cprint("Input ammount of money below.",10)
  86.   css.cprint("Input recipient account below.",14)
  87.   css.cprint("Current balance: " .. balance, 18)
  88.   css.sbc(colors.gray)
  89.   css.scp((w/2) - 10, 12)
  90.   write(string.rep(" ",20))
  91.   css.scp((w/2) - 10, 16)
  92.   write(string.rep(" ",20))
  93.   css.stc(colors.white)
  94.   css.scp((w/2) - 10, 12)
  95.   money = read()
  96.   css.scp((w/2) - 10, 16)
  97.   toaccount = read()
  98.  
  99.   --]] do transfer and money check logic here [[--
  100.   atm()
  101. end
  102.  
  103. function logout()
  104.   screen()
  105.   css.stc(colors.white)
  106.   css.cprint("Thank you for choosing",2)
  107.   css.cprint("Flyte Banking for the best",3)
  108.   css.cprint("banking experience.",4)
  109.   css.stc(colors.red)
  110.   css.sbc(colors.white)
  111.   for i =1, 5 do
  112.     css.cprint("|",12)
  113.     sleep(0.1)
  114.     css.rlprint("/")
  115.     sleep(0.1)
  116.     css.rlprint("-")
  117.     sleep(0.1)
  118.     css.rlprint("\\")
  119.   end
  120.  
  121.   --]] insert logout login here [[--
  122.   login()
  123.  
  124. end
  125.  
  126. function atm()
  127.   screen()
  128.   --]] draw stuff
  129.   css.stc(colors.white)
  130.   css.cprint("Welcome to Flyte ATM",2)
  131.   css.cprint("Select and Option below by",3)
  132.   css.cprint("clicking one with your mouse.",4)
  133.   css.cprint("Logged in as: " .. user, 6)
  134.   css.cprint("Remember to logout when finished!",8)
  135.   css.sbc(colors.white)
  136.   css.stc(colors.lightGray)
  137.   css.cprint("If there is a problem please contact",17)
  138.   css.cprint("Relative or Lewisk3 or NilLogic",18)
  139.   css.border((w/2) - 5, (h/2) + 1, (w/2) + 4, (h/2)+6, colors.orange)
  140.   menu:draw()
  141.  
  142.   while loggedin do
  143.      ev = {os.pullEvent()}
  144.  
  145.     value = menu:update(ev)
  146.      
  147.      if(value == options[1])then
  148.           deposit()
  149.      elseif(value == options[2])then
  150.           withdraw()
  151.      elseif(value == options[3])then
  152.           transfer()
  153.      elseif(value == options[4])then
  154.           logout()
  155.      end    
  156.   end
  157.  
  158. end
  159.  
  160. function signin()
  161.   screen()
  162.   css.stc(colors.white)
  163.   css.cprint("LOGIN",2)
  164.   css.cprint("Please enter account name",3)
  165.   css.cprint("and password below. ",4)
  166.   css.stc(colors.red)
  167.   css.sbc(colors.white)
  168.   css.cprint("Input Account Below.",10)
  169.   css.cprint("Input Password Below.",14)
  170.   css.sbc(colors.gray)
  171.   css.scp((w/2) - 10, 12)
  172.   write(string.rep(" ",20))
  173.   css.scp((w/2) - 10, 16)
  174.   write(string.rep(" ",20))
  175.   css.stc(colors.white)
  176.   css.scp((w/2) - 10, 12)
  177.   username = read()
  178.   css.scp((w/2) - 10, 16)
  179.   password = read("*")
  180.  
  181.   --]] handle login logic here [[--
  182.   user = username
  183.   atm()
  184.  
  185. end
  186.  
  187.  
  188. function register()
  189.   screen()
  190.   css.stc(colors.white)
  191.   css.cprint("Register",2)
  192.   css.cprint("Please enter a name",3)
  193.   css.cprint("and a password below. ",4)
  194.   css.stc(colors.red)
  195.   css.sbc(colors.white)
  196.   css.cprint("Input Username Below.",10)
  197.   css.cprint("Input Password Below.",14)
  198.   css.sbc(colors.gray)
  199.   css.scp((w/2) - 10, 12)
  200.   write(string.rep(" ",20))
  201.   css.scp((w/2) - 10, 16)
  202.   write(string.rep(" ",20))
  203.   css.stc(colors.white)
  204.   css.scp((w/2) - 10, 12)
  205.   username = read()
  206.   css.scp((w/2) - 10, 16)
  207.   password = read("*")
  208.  
  209.   --]] handle register logic here [[--
  210.   login()
  211.  
  212. end
  213.  
  214. function login()
  215.   local inLogin = true
  216.   local logopt = {
  217.       " Login  ",
  218.       "Register",
  219.   }
  220.  
  221.   log = css.createMenu(
  222.     math.floor((w/2))-4, math.floor((h/2)) + 3,
  223.     colors.orange,
  224.     colors.red,
  225.     0.5,
  226.     colors.red,
  227.     colors.white,
  228.     logopt
  229.   )
  230.  
  231.    screen()
  232.   --]] draw stuff
  233.   css.stc(colors.white)
  234.   css.cprint("Welcome to Flyte ATM",2)
  235.   css.cprint("Select and Option below by",3)
  236.   css.cprint("clicking one with your mouse.",4)
  237.   css.cprint("Please login to your account", 6)
  238.   css.sbc(colors.white)
  239.   css.stc(colors.lightGray)
  240.   css.cprint("If there is a problem please contact",17)
  241.   css.cprint("Relative or Lewisk3 or NilLogic",18)
  242.   css.border((w/2) - 5, (h/2) + 2, (w/2) + 4, (h/2)+5, colors.orange)
  243.   log:draw()
  244.  
  245.     while inLogin do
  246.        ev = {os.pullEvent()}
  247.    
  248.        value = log:update(ev)
  249.        
  250.        if(value == logopt[1])then
  251.           inLogin = false
  252.             signin()
  253.        elseif(value == logopt[2])then
  254.           inLogin = false
  255.             register()
  256.        end    
  257.     end
  258. end
  259.  
  260. login()
Add Comment
Please, Sign In to add comment