computercraft/recv_file
2021-01-09 04:05:20 +01:00

24 lines
450 B
Plaintext

dofile("/git-scripts/utils")
modemSide = utils.getSideOf("modem") --get side the modem is on
rednet.open(modemSide)
--get message, no timeout
id, msg, dist = rednet.receive()
print("Data received!")
--get filename
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)
--finish up
file.close()
rednet.close(modemSide)