Posted 07 April 2012 - 11:24 PM
Is it possible to send a program to another computer by rednet? If not are there any ways to do it besides floppy disks?
function sendFile(filename, ID) -- Opens a file and sends it as a single string
if fs.exists(filename) then
local fp = io.open( filename, "r" )
local content = ""
for line in fp:lines() do
content = content..line.."n"
end
fp:close()
rednet.send(ID, content)
else
error("Need to define a file name which exists")
end
end
function writeFile(String, filename) -- Receives a string and writes it into a file. Best with sendFile.
local fp = io.open( filename, "w" )
fp:write(String)
fp:close()
end
Spoiler
function sendFile(filename, ID) -- Opens a file and sends it as a single string if fs.exists(filename) then local fp = io.open( filename, "r" ) local content = "" for line in fp:lines() do content = content..line.."n" end fp:close() rednet.send(ID, content) else error("Need to define a file name which exists") end end function writeFile(String, filename) -- Receives a string and writes it into a file. Best with sendFile. local fp = io.open( filename, "w" ) fp:write(String) fp:close() end