Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local oldPull = os.pullEvent
- os.pullEvent = os.pullEventRaw
- --this program acts as a Credit Card, to make things less messy
- Requested_Amount = 0
- Requester_ID = 0
- Page = "Menu"
- --the following Data is Only Called when needed, then its deleted for security reasons
- AccountID = nil
- AccountName = nil
- AccountBalance = 0
- Key = 0
- start()
- term.setBackgroundColor("blue")
- term.setTextColor("white")
- Menu()
- function start()
- end
- function Menu()
- term.clear()
- term.setCursorPos(1,1)
- print("---Credit-Remote-Transfer-V-1.0---")
- local event, key = os.pullEvent("key")
- if Page == "Menu" then
- print("Options")
- print("1 - Wait for Request")
- print("2 - Check Account")
- print("3 - Exit")
- while true do
- if key == keys.1 then
- Page == "Request"
- Menu()
- else if key == keys.2 then --Opens AccountPage
- Page == "Account"
- Menu()
- else if key == keys.3 then --Takes User to Main Program
- shell.run("")
- end
- end
- else if Page == "Request" then
- term.setCursorPos(1,2)
- print("CONNECTION HANDLER")
- term.setCursorPos(1,3)
- textutils.slowWrite("Waiting for Connection.....",6]
- sleep(10)
- Receive()
- else if Page == "Account" then
- Decrypter()
- term.setCursorPos(1,2)
- print("--ACCOUNT PAGE--")
- print("Account Name - "..AccountName)
- print("Account ID - "..AccountID)
- print("Account Balance - $"..AccountBalance)
- AccountName = nil
- AccountBalance = nil
- AccountID = nil
- while true do
- if key == keys.enter then
- Page = "Menu"
- Menu()
- end
- end
- end
- end
- function Receive()
- Decrypter()
- rednet.receive(AccountID,5)
- Requester_ID = id
- rednet.send(Requester_ID,"Amount")
- rednet.receive(AccountID,5)
- Requested_Amount = message
- if Requested_Amount < 0 then
- if Account_Balance+Requested_Amount >=0 then
- Payment()
- else
- rednet.send(Requester_ID,"Denied")
- sleep(4)
- print("Transaction Denied due to insignificant Funds")
- sleep(6)
- Page = "Menu"
- Menu()
- end
- else
- Payment()
- end
- end
- function Payment()
- Decrypter()
- rednet.send(Requester_ID, "confirmed",Key)
- local h = fs.open(".SecuriedData","a")
- h.setCursorPos(1,4)
- local Decrypt = h.readline(5)
- h.writeline(h.readline(4)+(Requested_Amount*Decrpyt))
- h.close()
- Page = "Menu"
- print("Transfer Completed")
- AccountName = nil
- AccountBalance = nil
- AccountID = nil
- sleep(10)
- Menu()
- end
- function Decrypter()
- local h = fs.open(".BankDetails","r")
- AccountID = h.readline(2)
- AccountName = h.readline(3)
- local Encrypt_Balance = h.readline(4)
- local DecryptKey_Balance = h.readline(5)
- AccountBalance = Encrypt_Balance/DecryptKey_Balance
- h.close()
- end
- os.pullEvent = oldPull
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement