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

Help with my FTP

Started by Noodle, 12 April 2012 - 01:34 PM
Noodle #1
Posted 12 April 2012 - 03:34 PM

rednet.open("back")
rednet.open("right")
rednet.open("left")
rednet.open("top")
rednet.open("bottom")
local CompID == ""
function getUpdates()
sender, p1 = rednet.receive()
if sender == "CompID" and p1 == "update" then
local update = rednet.reveive()
fs.delete("NeXoS")
local hFile = fs.open("NeXoS", "w")
hFile.write(update)
end
sender, command = rednet.reveive()
if sender == "CompID" and command == "update"
print "Update Available"
print "You would like to update now?"
print "Y/N"
event, key = os.pullEvent()
  if event == "char" and key == "y" then
   getUpdates()
  elseif event == "char" and key == "n" then
   term.clear()
   term.setCursorPos(1,1)
  end
else
print "No Updates Available!"
end

That is the receive code


rednet.open("back")
term.clear()
term.setCursorPos(1,1)
rednet.broadcast("update")
local h = fs.open("/FTP/NeXoS", "r")
local update = h.readAll()
h.close()
rednet.broadcast(update)

That is the server broadcasting the update.


Can you help, I'm at school right now and I can't test this. Can you guys test and give me feedback and/or help with the errors?

Btw CompID isn't set yet because I don't know the ID's at school.
Advert #2
Posted 12 April 2012 - 04:39 PM
Read: http://www.computercraft.info/forums2/index.php?/topic/1063-try-to-figure-out-things-yourself-before-asking-questions/

There is no reason you can't wait until you're able to test this yourself.
Noodle #3
Posted 12 April 2012 - 09:27 PM
No no.. I know but I was at school and there was an error I wanted to see if you could help.
Wolvan #4
Posted 12 April 2012 - 10:39 PM
You can use my rednet advanced (rna) api.
It has a openAll and a sendFile()/writeIncoming() function. That would be exactly what you need as far as I know
Noodle #5
Posted 12 April 2012 - 11:54 PM
Yes thankyou!

You cant broadcast the files.. I need something more broad.
cant_delete_account #6
Posted 13 April 2012 - 12:26 AM
You cant broadcast the files.. I need something more broad.
You mean you can't rednet.broadcast them? If so, yes you can. It has this code:

if id == nil then
etc, etc.
else
etc, etc.
end
So, just don't type an ID.
Noodle #7
Posted 30 April 2012 - 10:46 PM
Fixed. Thanks.
BTW I'm not employed by nexus so this doesn't matter.