computercraft/recv_file
2021-01-09 03:55:07 +01:00

19 lines
407 B
Plaintext

dofile("utils")
modemSide = utils.getSideOf("modem") --get side the modem is on
rednet.open(modemSide)
--get message, no timeout
id, msg, dist = rednet.receive()
print("Received data:")
term.write("Output filename: ")
name = tostring(read())
--decompress string
content = textutils.unserialize(msg)
--write to file
local file = fs.open(name, "w")
file.write(content)
file.close()
rednet.close(modemSide)