Advertisement
RemiCraft

Bank Terminal Mobile

Jul 10th, 2022 (edited)
914
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.80 KB | None | 0 0
  1. --Variables--
  2. local UserAccount
  3. local userPIN
  4. local otherAccount
  5. local input
  6.  
  7. local senderId
  8. local message
  9. local protocol
  10.  
  11. --Setup Networking--
  12. rednet.open("back")
  13.  
  14. --Basic Functions--
  15. local function Clear()
  16.     term.clear()
  17.     term.setCursorPos(1,1)
  18. end
  19.  
  20. local function SendMoney()
  21.     Clear()
  22.     term.write("Input Account Name:")
  23.     term.setCursorPos(1,2)
  24.     userAccount = read()
  25.     term.setCursorPos(1,3)
  26.     term.write("Input Account To Send Money To:")
  27.     term.setCursorPos(1,4)
  28.     otherAccount = read()
  29.     term.write("Input Amount Of Money To Send:")
  30.     term.setCursorPos(1,6)
  31.     amount = read()
  32.     term.setCursorPos(1,7)
  33.     term.write("Enter PIN:")
  34.     term.setCursorPos(1,8)
  35.     userPIN = read("*")
  36.     rednet.send(11, "SendMoney", "bankFunction")
  37.     senderId, message, protocol = rednet.receive("confirmation")
  38.     if message == "confirmed" then
  39.         rednet.send(11, userAccount,"bankSend")
  40.     else
  41.         clear()
  42.         term.write("Connection To Bank Server Not Established")
  43.         os.sleep(3)
  44.         os.reboot()
  45.     end
  46.     senderId, message, protocol = rednet.receive("confirmation")
  47.     if message == "confirmed" then
  48.         rednet.send(11, otherAccount,"bankSend")
  49.     else
  50.         clear()
  51.         term.write("Connection To Bank Server Not Established")
  52.         os.sleep(3)
  53.         os.reboot()
  54.     end
  55.     senderId, message, protocol = rednet.receive("confirmation")
  56.     if message == "confirmed" then
  57.         rednet.send(11, amount,"bankSend")
  58.     else
  59.         clear()
  60.         term.write("Connection To Bank Server Not Established")
  61.         os.sleep(3)
  62.         os.reboot()
  63.     end
  64.     senderId, message, protocol = rednet.receive("confirmation")
  65.     if message == "confirmed" then
  66.         rednet.send(11, userPIN,"bankSend")
  67.     else
  68.         clear()
  69.         term.write("Connection To Bank Server Not Established")
  70.         os.sleep(3)
  71.         os.reboot()
  72.     end
  73.     senderId, message, protocol = rednet.receive("bankStatus")
  74.     Clear()
  75.     term.write(message)
  76.     os.sleep(3)
  77.     os.reboot()
  78. end
  79.  
  80. local function CheckBalance()
  81.     Clear()
  82.     term.write("Input Account Name:")
  83.     term.setCursorPos(1,2)
  84.     userAccount = read()
  85.     term.setCursorPos(1,3)
  86.     term.write("Enter PIN:")
  87.     term.setCursorPos(1,4)
  88.     userPIN = read("*")
  89.     rednet.send(11, "CheckBalance", "bankFunction")
  90.     senderId, message, protocol = rednet.receive("confirmation")
  91.     if message == "confirmed" then
  92.         rednet.send(11, userAccount,"balanceCheck")
  93.     else
  94.         clear()
  95.         term.write("Connection To Bank Server Not Established")
  96.         os.sleep(3)
  97.         os.reboot()
  98.     end
  99.     senderId, message, protocol = rednet.receive("confirmation")
  100.     if message == "confirmed" then
  101.         rednet.send(11, userPIN,"balanceCheck")
  102.     else
  103.         clear()
  104.         term.write("Connection To Bank Server Not Established")
  105.         os.sleep(3)
  106.         os.reboot()
  107.     end
  108.     senderId, message, protocol = rednet.receive("bankStatus")
  109.     if message ~= "confirmed" then
  110.         Clear()
  111.         term.write(message)
  112.         os.sleep(3)
  113.         os.reboot()
  114.     else
  115.         senderId, message, protocol = rednet.receive("bankCheck")
  116.         Clear()
  117.         term.write("Your Balance Is: " .. message)
  118.         term.setCursorPos(1,2)
  119.         term.write("Press Any Key To Continue")
  120.         os.pullEvent("key")
  121.         os.reboot()
  122.     end
  123. end
  124.  
  125. Clear()
  126. term.write("Ranch Financial Banking")
  127. term.setCursorPos(1,2)
  128. term.write("1). Send Money")
  129. term.setCursorPos(1,3)
  130. term.write("2). Check Balance")
  131. term.setCursorPos(1,4)
  132. term.write("3). Exit")
  133. term.setCursorPos(1,5)
  134. input = read()
  135. if input == "1" then
  136.     SendMoney()
  137. elseif input == "2" then
  138.     CheckBalance()
  139. elseif input == "3" then
  140.     shell.exit()
  141. else
  142.     os.reboot()
  143. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement