I have tried some things, but cant make it work except if I put everything in the file to send on 1 line!
please help…… thanx in advance
function sendFile(inFile) -- Needs to be a table/file from fs.open or io.open,and in read mode.
local outtro
while true do
testro = inFile.readLine()
if testro then
outtro = outtro .. "n" .. testro
else break end
end
return outtro
end
function sendFileSep(target, inFile) -- target need to be a vaild computer. inFile needs to be a table/file from fs.open or io.open,and in read mode.
while true do
testro = inFile.readLine()
if testro then
rednet.send(target)
else break end
end
end
or do this:Mmm.
Okay so first: how are you parsing the programs to a line presently? Because, it might look something like this.function sendFile(inFile) -- Needs to be a table/file from fs.open or io.open,and in read mode. local outtro while true do testro = inFile.readLine() if testro then outtro = outtro .. "n" .. testro else break end end return outtro end
That would dump a file into a line with line breaks, ready for sending. You might even be able to call the function in the send call.
The other way would befunction sendFileSep(target, inFile) -- target need to be a vaild computer. inFile needs to be a table/file from fs.open or io.open,and in read mode. while true do testro = inFile.readLine() if testro then rednet.send(target) else break end end end
I don't know that either way will work great, or at all, but they should.
function sendFile(inFile) -- is only the direction i changed that
local inFile = fs.open(inFile,"r")
local outtro ={}
while true do
local testro = inFile.readLine()
if testro then
table.insert(outtro,testro)
else break end
end
return textutils.serialize(outtro)
end
reciever:
function recieveFile(inString,Savepath) -- Serialized string and Savepath
local file = fs.open(Savepath,"w")
local data=textutils.unserialize(inString)
for x=1,#data do
file.writeLine(data[x])
end
file.close()
end
toOut = sendFile(file)
rednet.send(target, toOut)
flipped = rednet.receive()
function sendFile(inFile) -- is only the direction i changed that
local inFile = fs.open(inFile,"r")
local outtro ={}
while true do
local testro = inFile.readLine()
if testro then
table.insert(outtro,testro)
else break end
end
inFile.close()
return textutils.serialize(outtro)
end
data = sendFile("filename")
rednet.send(pcid,data)
reciever:
function recieveFile(inString,Savepath) -- Serialized string and Savepath
local file = fs.open(Savepath,"w")
local data=textutils.unserialize(inString)
for x=1,#data do
file.writeLine(data[x])
end
file.close()
end
_,text = rednet.receive()
recieveFile(text,"path")
file = fs.open("test", "r")
toOut = sendFile(file)
file.close()
rednet.send(target, toOut)
inFile = rednet.receive()
file = fs.open("test2", "w")
file.close() -- Should make the file for you
receiveFile(inFile, "test2")
nah do the close too i forgot that let me edit it 1 seckolpa: should i only add the line: sendFile = fs.open("test", "r") ?
rednet.open("right")
print ("Please enter the receiver ID: ")
ID = read()
print ("Please enter the file directory: ")
filename = io.read()
inFile = fs.open(filename, "r")
function sendFile (inFile)
local outtro={}
while true do
testro = inFile.readLine()
if testro then
table.insert(outtro,testro)
else break end
end
return textutils.serialize(outtro)
end
file = fs.open(filename, "r")data = sendFile(file)
file.close()
rednet.send(ID,data)
print ("File send!")
</name>rednet.open("right")
print ("Please enter filename: ")
Savepath = read()
function recieveFile(inString,Savepath)
file = fs.open(Savepath,"w")
local data=textutils.unserialize(inFile)
for x,#data do
file.writeLine(data[x])
end
file.close()
end
_,text = rednet.receive()
recieveFile(text,path)
rednet.open("right")
print ("Please enter the receiver ID: ")
ID = assert(tonumber(read()), "Not a number")
print ("Please enter the file directory: ")
filename = io.read()
inFile = fs.open(filename, "r")
function sendFile (inFile)
local outtro={}
while true do
testro = inFile.readLine()
if testro then
table.insert(outtro,testro)
else break end
end
return textutils.serialize(outtro)
end
file = fs.open(filename, "r")data = sendFile(file)
file.close()
rednet.send(ID,data)
print ("File send!")
and (receiver):
rednet.open("right")
print ("Please enter filename: ")
Savepath = read()
function recieveFile(inString,Savepath)
file = fs.open(Savepath,"w")
local data=textutils.unserialize(inFile)
for onlyalittlenumber=x,#data do
file.writeLine(data[x])
end
file.close()
end
_,text = rednet.receive()
recieveFile(text,path)
x = rednet.receive()
print(x)
You can send whole programs thru rednet and wifi - (i did this with the adventure program which is 1500+ lines when modems first came out in beta)
To the person above me, your signature is too big.
rednet.open("right")
print ("Please enter filename: ")
Savepath = read()
function recieveFile(inString,Savepath)
file = fs.open(Savepath,"w")
local data=textutils.unserialize(inFile)
for onlyalittlenumber=x,#data do
file.writeLine(data[x])
end
file.close()
end
_,text = rednet.receive()
recieveFile(text, Savepath)
rednet.open("right")
print ("Please enter filename: ")
Savepath = read()
function recieveFile(inString,Savepath)
file = fs.open(Savepath,"w")
local data=textutils.unserialize(inString)
for onlyalittlenumber=x,#data do
file.writeLine(data[x])
end
file.close()
end
_,text = rednet.receive()
recieveFile(text, Savepath)
rednet.open("right")
print ("Please enter filename: ")
Savepath = read()
function recieveFile(inString,Savepath)
file = fs.open(Savepath,"w")
local data=textutils.unserialize(inString)
for onlyalittlenumber=1, #data do
file.writeLine(data[x])
end
file.close()
end
_,text = rednet.receive()
recieveFile(text, Savepath)
rednet.open("right")
print ("Please enter filename: ")
Savepath = read()
function recieveFile(inString,Savepath)
file = fs.open(Savepath,"w")
local data=textutils.unserialize(inString)
for onlyalittlenumber=1, #data do
file.writeLine(data[onlyalittlenumber])
end
file.close()
end
_,text = rednet.receive()
recieveFile(text, Savepath)
Now all bugs should be fixed…Next error found:Now all bugs should be fixed…rednet.open("right") print ("Please enter filename: ") Savepath = read() function recieveFile(inString,Savepath) file = fs.open(Savepath,"w") local data=textutils.unserialize(inString) for onlyalittlenumber=1, #data do file.writeLine(data[onlyalittlenumber]) end file.close() end _,text = rednet.receive() recieveFile(text, Savepath)
Now it should be fixed…
Huh … Who coded the base code?
function sendFile(inFile) -- is only the direction i changed that
local inFile = fs.open(inFile,"r")
local outtro ={}
while true do
local testro = inFile.readLine()
if testro then
table.insert(outtro,testro)
else break end
end
return textutils.serialize(outtro)
end
function recieveFile(inString,Savepath) -- Serialized string and Savepath
local file = fs.open(Savepath,"w")
local data=textutils.unserialize(inString)
for x=1,#data do
file.writeLine(data[x])
end
file.close()
end
raw = sendFile("new")
recieveFile(raw,"test")
function sendFile(inFile) -- is only the direction i changed that
local inFile = fs.open(inFile,"r")
local outtro ={}
while true do
local testro = inFile.readLine()
if testro then
table.insert(outtro,testro)
else break end
end
return textutils.serialize(outtro)
end
function mod() --this finds the location of the modem
for n,sSide in pairs(rs.getSides()) do
if peripheral.getType(sSide) == "modem" then
side = sSide
break
end
end
return side
end
rednet.open(mod())
rednet.broadcast(sendFile("newTest"))
function recieveFile(inString,Savepath) -- Serialized string and Savepath
local file = fs.open(Savepath,"w")
local data=textutils.unserialize(inString)
for x=1,#data do
file.writeLine(data[x])
end
file.close()
end
function mod() --this finds the location of the modem
for n,sSide in pairs(rs.getSides()) do
if peripheral.getType(sSide) == "modem" then
side = sSide
break
end
end
return side
end
rednet.open(mod())
_,txt = rednet.receive()
filename = "newTest"
recieveFile(txt,filename)
shell.run(filename)
that's weird it works fine for me o.O please post the whole erroruuuuuhm, sorry for the late post, I probably fucked up, but it doesnt work either……….
are you playing on a server of some sort ? it would help me being able to look over the data (also try to start a new world this code try's to write the 1. message it gets to a file so if anything is broadcasting near you it will interfere)no error, file is just empty
BTW, school started, so thats the reason for late posts