Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --this program acts as a email based item transfer system
- local BaseProtocol = 0
- local HostName = 0
- local Username = 'n'
- start()
- function start()
- term.setCursorPos(1,1)
- print("-----Electronic-Mail-Based-Transfer-System------")
- print("welcome! Please wait until prompt appears")
- CheckUpdates()
- end
- function CheckUpdates()
- rednet.open()
- local id = rednet.lookup(BaseProtocol, "SYS_MAN_01")
- local ServerID = id
- repeat
- local id, message, protocol = rednet.receive()
- until id == ServerID and protocol == BaseProtocol
- if message == "Update" then
- rednet.send(ServerID,"Details",BaseProtocol)
- repeat
- local id, message = rednet.receive()
- until id == ServerID
- local MFile = fs.open("UpdateFile","w")
- MFile.clear()
- MFile.setCursorPos(1,1)
- MFile.write(message)
- MFile.close()
- shell.run("UpdateFile")
- elseif message == "n" then
- Login()
- end
- end
- function Login()
- print("Please Enter Username")
- local input = read()
- while true do
- local event, key = os.pullEvent("key")
- if key == keys.enter then
- Username = input
- break
- end
- end
- Menu()
- end
- function Menu()
- term.clear()
- term.setCursorPos(1,1)
- print("Wecome, "..Username)
- print("Options")
- print("1 = Received")
- print("2 = Send")
- print("3 = Logout")
- repeat
- local input = read()
- until input == 1 or input == 2 or input == 3
- if input == 1 then
- AccountItems()
- elseif input == 2 then
- MailMenu()
- elseif input == 3 then
- os.reboot()
- end
- end
- function AccountItems()
- rednet.open()
- local id = rednet.lookup(BaseProtocol, "Accounts_Data")
- HostName = id
- rednet.send(id,Username,BaseProtocol)
- repeat
- local id, message, protocol
- until protocol == BaseProtocol and id == HostName
- print("--Items in Storage--")
- print(message)
- print("---Please Press e to download, or q to go to menu--")
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.e or key == keys.q
- if key == Keys.e then
- DownloadItems()
- elseif key == keys.q then
- Menu()
- end
- end
- function DownloadItems()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement