113 posts
Posted 30 July 2012 - 08:44 PM
How do I take a file on my computer and send it through rednet? So I would want to be able to use
fs.copy()
fs.open()
fs.read()
fs.delete()
etc.
34 posts
Location
Programming Land
Posted 30 July 2012 - 11:01 PM
I'm very experienced with Rednet so if you need any other help just message me. Here's the code.
id = 3 -- Receiving computer id here
side = "top" --Modem side here
rednet.open(side)
file = io.open("data")
filedata = file:read()
file:close()
rednet.send(id, filedata)
And here's some extra code for the receiver
side = "top" -Modem side
rednet.open(side)
file = io.open("data", "w")
id, msg = rednet.receive()
file:write(msg)
file:close()
EDIT: You have to send the file line by line or it will be like this:
tArgs = {...}if #tArgs < 1 or #tArgs > 1 then print("Usage: setup <modemside>") return endsSide = shell.resolve(tArgs[1])rootDir = ""local file = io.open(fs.combine(rootDir, "pref"), "w")if file then file:write("side="..sSide) file:close()end