Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Server side (Updated for continuous admin log display and server status)
- -- 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 server 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 ID: " .. tostring(serverID))
- monitor.setCursorPos(1, 2)
- monitor.write("Server Online")
- monitor.setCursorPos(1, 4)
- monitor.write(statusMessage)
- -- Keep displaying the log
- while true do
- sleep(2) -- Adjust the duration between log updates
- monitor.scroll(1) -- Scroll the monitor content
- monitor.setCursorPos(1, 4)
- monitor.write(" ") -- Clear previous log message
- monitor.setCursorPos(1, 4)
- monitor.write(statusMessage) -- Display the updated log message
- end
- 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