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

How to make a File Transfer program (line 10: attempt to call nil)

Started by houseofkraft, 01 September 2016 - 03:54 PM
houseofkraft #1
Posted 01 September 2016 - 05:54 PM
Hi Guys im trying to make a work room but i am having issues with making a file transfer. I want it to transfer the program file in the folder to the PC

Server:
term.clear()
rednet.open("top")
print("---------------")
print("Download Server")
print("---------------")
print()
print("Active.")
while true do
id, message = rednet.receive()
if message == "houseofkraft" then
   print("/houseofkraft/program >> WORK-PC")
   code = fs.open("/houseofkraft/program", "r")
   file = code.readAll()
   rednet.send(id, "filereceive", file)
end
end

Client:
term.clear()
term.setCursorPos(1,1)
print("Please swipe Smart Card")
mag = peripheral.wrap("right")
mag.setInsertCardLight(true)
p1, p2, p3 = os.pullEvent()
mag.setInsertCardLight(false)
if p2 == "houseofkraft" then
   term.clear()
   term.setCursorPos(1,1)
   print("Welcome houseofkraft!")
   print("Downloading files...")
   rednet.open("top")
   rednet.broadcast("houseofkraft")
   id, message, file = rednet.receive()
   if message == "filereceive" then
	  code = file.readAll()
	  textutils.slowPrint(code)
	  shell.run("mkdir", "/myWork")
	  shell.run("cd", "/myWork")
	  file2 = fs.open("program", "w")
	  file2.write(code)
	  file2.close()
   end
else
   term.clear()
   term.setCursorPos(1,1)
   print("Access Denied!")
   os.sleep(1)
   os.shutdown()
end

I am getting an error that says "line 10: attempt to call nil"
Which probably means im doing it wrong

EDIT: The client is getting the Error

Thank You!
Edited on 01 September 2016 - 04:32 PM
KingofGamesYami #2
Posted 01 September 2016 - 06:19 PM
Line 10 of which script? Neither of the ones you posted are calling functions on line 10 and therefore wouldn't throw that error.
houseofkraft #3
Posted 01 September 2016 - 06:32 PM
The Client has the error
CCJJSax #4
Posted 01 September 2016 - 07:11 PM
just to make sure there is no previous lines of code on the client, is line 10 term.setCursorPos(1, 1) ?