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

FileNet API (Send Files Trough Rednet)

Started by lolmaker2002, 30 August 2015 - 08:17 PM
lolmaker2002 #1
Posted 30 August 2015 - 10:17 PM
im sure theres a lot of alternatives like this one out there but why not, im going to introduce you to my API:

FileNet

Simple Wireless File Sender


Its Verry simple actually, the API allows you to send files trough rednet

Examples:

in your program, try this


--[[To Load Up The API]]--
os.loadAPI("FileNet")
--[[For Computer That Recieves]]--
FileNet.ReceiveFile("top") -- replace "top" with a the side where the modem is
--[[For The Computer That Sends]]--
FileNet.BroadcastFile("YourFile", "top") --to send the file to everyone who is using FileNet.receive()
FileNet.SendFileToID("YourFile", "1", "top" ) --to send a file to an id,replace "YourFile" with the file, replace "1" with the computer ID & relace "top" with the location of the modem

So, thats pretty much it, if you want to use it, here's the paste:

pastebin get 0xTUEGjC FileNet


Already Thank You For Checking This Out! :D/>
Edited on 30 August 2015 - 08:18 PM
LDDestroier #2
Posted 31 August 2015 - 01:13 AM
I reccommend you add an optional argument for FileNet.RecieveFile() to filter the id, so that you don't get someone else's files.
Lewisk3 #3
Posted 06 September 2015 - 07:50 PM
I reccommend you add an optional argument for FileNet.RecieveFile() to filter the id, so that you don't get someone else's files.
i agree, maybe change your receive function to this

function ReceiveFile(filterid,side)
	    id,msg = rednet.recieve()
	    if msg == "P/:F&" and id == filterid then
			    id2, msg2 = rednet.receive()
			    f = fs.open(msg2, "w")
			    id3,msg3 = rednet.recieve()
			    f.write(msg3)
			    f.close()
			    print("Got File "..msg2.." from computer #"..id)
			    sleep(5)
	    end
end