This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Pth1515's profile picture

Sending files over rednet

Started by Pth1515, 26 June 2016 - 11:05 PM
Pth1515 #1
Posted 27 June 2016 - 01:05 AM
Every time I try to send a file to my other computer with rednet it fails due to rednet:87: Expected number. And yes, I have tried using tonumber to convert the string value. Here are the links to the programs: Sendfile: http://pastebin.com/fj5wxhNi Getfile: http://pastebin.com/5iTL2hZu
Dog #2
Posted 27 June 2016 - 01:13 AM
You have your arguments reversed on lines 8 and 9. It's rednet.send(id, message), not rednet.send(message, id)
Edited on 26 June 2016 - 11:15 PM
Pth1515 #3
Posted 27 June 2016 - 01:15 AM
You have your arguments reversed on lines 8 and 9. It's rednet.send(id, message), not rednet.send(message, id)
Well now I feel stupid…. Thanks! :)/>
The Higher Realm #4
Posted 27 June 2016 - 01:25 AM
It's because you got the rednet arguments confused. Its…

rednet.send(id, msg)



This should work for the sending.


rednet.open("top")

tArgs = {...}
id = tonumber(tArgs[2])

if fs.exists(tArgs[1]) then
    textutils.slowPrint("Sending File "..tArgs[1].."...")
    rednet.send(id, "FileTransfer")
  print("Sent File Transfer")
    rednet.send(id, tArgs[1])
    file = fs.open(tArgs[1], "r")
    rednet.send(id, file.readAll())
    else
print(tArgs[1].." does not exist.")
end
Edited on 26 June 2016 - 11:27 PM
Pth1515 #5
Posted 27 June 2016 - 01:33 AM
Thanks, I just realized I accidentally posted two threads so I don't really know what to do about that….

Some how they merged?
Lupus590 #6
Posted 27 June 2016 - 02:42 PM
Some how they merged?

moderators are stealthy