SHARE
TWEET

BankAccess1

a guest Jun 30th, 2018 31 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. os.loadAPI("touchpoint")
  2. modem = peripheral.wrap("back")
  3.  
  4. function CheckBalance(user)
  5.  
  6. print("Checking Balance" .. tostring(user))
  7. modem.transmit(user, 2, "balance")
  8. modem.open(user)
  9. local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  10. term.clear()
  11. term.setBackgroundColor(colors.black)
  12. term.clear()
  13. term.setCursorPos(1,1)
  14. print(message)
  15.  
  16. local event, button, x, y = os.pullEvent("mouse_click")
  17.  
  18. end
  19.  
  20. function SendMoney(user)
  21.  
  22.   term.setBackgroundColor(colors.black)
  23.   term.clear()
  24.   term.setCursorPos(1,1)
  25.   print("Who do you want to send money to?")
  26.   local receiver = tonumber(read())
  27.   print("How much money?")
  28.   local value = tonumber(read())
  29.  
  30.   modem.transmit(user, 3, receiver)
  31.   sleep(0.1)
  32.   modem.transmit(user, 3, value)
  33.  
  34.   local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  35.  
  36.   term.setBackgroundColor(colors.black)
  37.   term.clear()
  38.   term.setCursorPos(1,1)
  39.   print(message)
  40.  
  41.   local event, button, x, y = os.pullEvent("mouse_click")
  42.  
  43. end
  44.  
  45. function Close()
  46.  
  47.   term.clear()
  48.   term.setBackgroundColor(colors.black)
  49.   term.clear()
  50.   term.setCursorPos(1,1)
  51.   error()
  52.  
  53. end
  54.  
  55. print("Enter User Number")
  56. local user = tonumber(read())
  57. print("Enter User Password")
  58. local password = read()
  59.  
  60. print(user)
  61. if user~= nil then
  62. modem.transmit(user, 1, password)
  63. else
  64. term.setBackgroundColor(colors.black)
  65. term.clear()
  66. term.setCursorPos(1,1)
  67. print("Wrong Username")
  68. error()
  69.  
  70. end
  71. modem.open(user)
  72.  
  73. local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  74.  
  75. print(message)
  76. sleep(1)
  77. term.setBackgroundColor(colors.black)
  78. term.clear()
  79. term.setCursorPos(1,1)
  80.  
  81. if (message == "Approved") then
  82.  
  83.  
  84.     while true do
  85.       sleep(1)
  86.       term.clear()
  87.      
  88.       local t = touchpoint.new()
  89.       local event, p1
  90.       t:add("Balance", function() CheckBalance(user) end, 1,1,15,5, colors.red, colors.lime)
  91.       t:add("Send Money", function() SendMoney(user) end, 1,7,15,11,colors.red, colors.lime)
  92.       t:add("Exit", function() Close() end,1,13, 15, 17, colors.red, colors.black)
  93.       t:draw()
  94.    
  95.       event, p1 = t:handleEvents(os.pullEvent())
  96.       if event == "button_click" then
  97.         t.buttonList[p1].func()
  98.       end
  99.      
  100.      end
  101.    
  102. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top