RemiCraft

Bank Terminal Dev

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