Jump to content




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


  • You cannot reply to this topic
3 replies to this topic

#1 houseofkraft

  • Members
  • 170 posts
  • LocationUSA

Posted 01 September 2016 - 04: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 by houseofkraft, 01 September 2016 - 05:32 PM.


#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 01 September 2016 - 05: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.


#3 houseofkraft

  • Members
  • 170 posts
  • LocationUSA

Posted 01 September 2016 - 05:32 PM

The Client has the error

#4 CCJJSax

  • Members
  • 262 posts

Posted 01 September 2016 - 06:11 PM

just to make sure there is no previous lines of code on the client, is line 10 term.setCursorPos(1, 1) ?





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users