Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("touchpoint")
- modem = peripheral.wrap("back")
- function CheckBalance(user)
- print("Checking Balance" .. tostring(user))
- modem.transmit(user, 2, "balance")
- modem.open(user)
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- term.clear()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- print(message)
- local event, button, x, y = os.pullEvent("mouse_click")
- end
- function SendMoney(user)
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- print("Who do you want to send money to?")
- local receiver = tonumber(read())
- print("How much money?")
- local value = tonumber(read())
- modem.transmit(user, 3, receiver)
- sleep(0.1)
- modem.transmit(user, 3, value)
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- print(message)
- local event, button, x, y = os.pullEvent("mouse_click")
- end
- function Close()
- term.clear()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- error()
- end
- print("Enter User Number")
- local user = tonumber(read())
- print("Enter User Password")
- local password = read()
- print(user)
- if user~= nil then
- modem.transmit(user, 1, password)
- else
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- print("Wrong Username")
- error()
- end
- modem.open(user)
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- print(message)
- sleep(1)
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- if (message == "Approved") then
- while true do
- sleep(1)
- term.clear()
- local t = touchpoint.new()
- local event, p1
- t:add("Balance", function() CheckBalance(user) end, 1,1,15,5, colors.red, colors.lime)
- t:add("Send Money", function() SendMoney(user) end, 1,7,15,11,colors.red, colors.lime)
- t:add("Exit", function() Close() end,1,13, 15, 17, colors.red, colors.black)
- t:draw()
- event, p1 = t:handleEvents(os.pullEvent())
- if event == "button_click" then
- t.buttonList[p1].func()
- end
- end
- end
Add Comment
Please, Sign In to add comment