Advertisement
itachi1706

Transfer Programs Computercraft

Jun 27th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.58 KB | None | 0 0
  1. function sendFile(filename, ID) -- Opens a file and sends it as a single string
  2.   if fs.exists(filename) then
  3.         local fp = io.open( filename, "r" )
  4.         local content = ""
  5.         for line in fp:lines() do
  6.           content = content..line.."n"
  7.         end
  8.         fp:close()
  9.         rednet.send(ID, content)
  10.   else  
  11.         error("Need to define a file name which exists")
  12.   end
  13. end
  14.  
  15. function writeFile(String, filename) -- Receives a string and writes it into a file. Best with sendFile.
  16.   local fp = io.open( filename, "w" )
  17.   fp:write(String)
  18.   fp:close()
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement