Advertisement
Guest User

startup

a guest
Jul 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.89 KB | None | 0 0
  1. local event
  2. local key
  3. local stop
  4. local amount
  5. local pass
  6. local ID
  7. local message
  8. local protocol
  9.  
  10. function ret()
  11.   print("Returning to home screen...")
  12.   sleep(2.5)
  13. end
  14.  
  15. function inv()
  16.   print("Invalid input!")
  17.   ret()
  18. end
  19.  
  20. function amt()
  21.   print("How much? Please type a numerical amount below.")
  22.   event, key = os.pullEvent("key")
  23.   amount = read()
  24.   print(amount .. " coin(s)? Y/N")
  25. end
  26.  
  27. function sd()
  28.   print("Success!")
  29.   print("Goodbye!")
  30.   stop = 1
  31.   sleep(2.5)
  32. end
  33.  
  34. term.clear()
  35. term.setCursorPos(1,1)
  36. stop = 0
  37. rednet.open("back")
  38. repeat
  39.   print("Welcome to the OTS ATM Network!")
  40.   print("Please press W to withdraw or D to deposit.")
  41.   event, key = os.pullEvent("key")
  42.   if key == 17 then
  43.     print("Withdrawal? Y/N")
  44.     event, key = os.pullEvent("key")
  45.     if key == 21 then
  46.       amt()
  47.       event, key = os.pullEvent("key")
  48.       if key == 21 then
  49.         rednet.send(5,amount,"atm.buy")
  50.         print("Transaction sent! Please see game chat for more.")
  51.         ret()
  52.       elseif key == 49 then
  53.         ret()
  54.       else
  55.         inv()
  56.       end
  57.     elseif key == 49 then
  58.       ret()
  59.     else
  60.       inv()
  61.     end
  62.   elseif key == 32 then
  63.     print("Deposit? Y/N")
  64.     event, key = os.pullEvent("key")
  65.     if key == 21 then
  66.       amt()
  67.       event, key = os.pullEvent("key")
  68.       if key == 21 then
  69.         rednet.send(5,amount,"atm.sell")
  70.         print("Transaction sent! Please see game chat for more.")
  71.         ret()
  72.       elseif key == 49 then
  73.         ret()
  74.       else
  75.         inv()
  76.       end
  77.     elseif key == 49 then
  78.       ret()
  79.     else
  80.       inv()
  81.     end
  82.   elseif key == 211 then
  83.     print("Shutdown ATM? Y/N")
  84.     event, key = os.pullEvent("key")
  85.     if key == 21 then
  86.       print("Please enter network password below, or E to exit.")
  87.       event, key = os.pullEvent("key")
  88.       pass = read()
  89.       if pass == "E" then
  90.         ret()
  91.       elseif pass == "e" then
  92.         ret()
  93.       else
  94.         print("Waiting on response from master server...")
  95.         rednet.send(5,pass,"atm.stop")
  96.         ID, message, protocol = rednet.receive("atm.stop",5)
  97.         if ID == 5 then
  98.           if message == "OKAY" then
  99.             sd()
  100.           elseif message == "NO" then
  101.             print("Unauthorized user!")
  102.             ret()
  103.           else
  104.             print("Hmm... Something went wrong.")
  105.             ret()
  106.           end
  107.         else
  108.           print("No response, master server may be down.")
  109.           print("Please enter local backup password below.")
  110.           event, key = os.pullEvent("key")
  111.           pass = read()
  112.           if pass == "artemis25" then
  113.             sd()
  114.           else
  115.             inv()
  116.           end
  117.         end
  118.       end
  119.     elseif key == 49 then
  120.       ret()
  121.     else
  122.       inv()
  123.     end
  124.   else
  125.     inv()
  126.   end
  127.   term.clear()
  128.   term.setCursorPos(1,1)
  129. until stop == 1
  130. rednet.close("back")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement