Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Server side (Updated to display status and server ID on the right monitor)
- -- Make sure the modem is open on the side you're using
- rednet.open("top") -- Replace "top" with the side where your modem is placed
- -- Function to display server status and ID on the right monitor
- local function displayStatus(statusMessage, serverID)
- local monitor = peripheral.wrap("right") -- Replace "right" with the side where your monitor is connected
- monitor.clear()
- monitor.setCursorPos(1, 1)
- monitor.write("Server Status:")
- monitor.setCursorPos(1, 2)
- monitor.write(statusMessage)
- monitor.setCursorPos(1, 4)
- monitor.write("Server ID: " .. tostring(serverID))
- -- Display for 5 seconds
- sleep(5)
- monitor.clear()
- end
- -- Function to handle displaying status and server ID
- local function displayServerStatus(senderID, message)
- print("Received file from ID: " .. senderID)
- -- Save the file to the DGOS directory
- local file = fs.open("DGOS/" .. message.fileName, "w")
- file.write(message.fileContent)
- file.close()
- print("File saved as " .. message.fileName)
- -- Display server status and server ID on the right monitor
- local statusMessage = "File received from ID: " .. senderID .. "\nFile saved as " .. message.fileName
- displayStatus(statusMessage, senderID)
- end
- while true do
- local senderID, message, protocol = rednet.receive()
- if protocol == "file_transfer" then
- displayServerStatus(senderID, message)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement