Advertisement
ElijahCrafter

WIP

Jul 5th, 2024 (edited)
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1.  rednet.open("back")
  2.  
  3.  
  4.  
  5.  
  6. local function receiveFile(targetPath, contents)
  7.     local file = fs.open(targetPath, "w")
  8.     if file then
  9.         file.write(contents)
  10.         file.close()
  11.         print("Received file: " .. targetPath)
  12.     else
  13.         print("Error: Unable to save file " .. targetPath)
  14.     end
  15. end
  16.  
  17.  
  18.  
  19.  
  20. while true do
  21.         local senderID, message, protocol = rednet.receive("fileTransfer")
  22.         if type(message) == "table" and #message == 2 then
  23.             local targetPath = message[1]
  24.             local contents = message[2]
  25.             receiveFile(targetPath, contents)
  26.         end
  27.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement