Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modem = peripheral.find("modem") or error("No modem attached", 0)
- modem.open(57)
- function Loop()
- while true do
- local event, a, b, c, d, e, f, g = os.pullEvent()
- if event == "modem_message" then
- local ReplyChannel = c
- local Message = d
- local Distance = e
- local Data = textutils.unserialize(Message)
- local Pin = Data[1]
- local Account = Data[2]
- local Amount = Data[3]
- if Transfer(Pin,Account,Amount) == true then
- local Re = textutils.serialize({Account,"accepted"})
- modem.transmit(ReplayChannel,57,Re)
- end
- else
- end
- os.queueEvent("pass")
- end
- end
- function Transfer(pin,account,amount)
- local file = fs.open(fs.combine("Accounts",account,"Details.txt"),"r")
- local ConfirmPin = file.readLine()
- local Balance = file.readLine()
- file.close()
- if ConfirmPin == pin then
- Balance = Balance + amount
- local Doc = fs.open(fs.combine("Accounts",account,"Details.txt"),"w")
- Doc.writeLine(ConfirmPin)
- Doc.writeLine(Balance)
- Doc.Close()
- return true
- end
- end
- Loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement