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

[lua][error] A magic 13

Started by Mazi30, 05 May 2012 - 02:24 PM
Mazi30 #1
Posted 05 May 2012 - 04:24 PM
Hi I created a program that send file to another computer. Next I wanted it(the same program) to run program on other computer. I probably mess up something because when I try to run this, it print's 13 . I checked code 3 times, but I still have no idea what's wrong.



side="top"

function err()
cl()
print('Blad')
sleep(2)
cl()
main()
end

function cl()
term.clear()
term.setCursorPos(1,1)
print("t1.1\nTest kundy mFTP")
sleep(1)
end

function main()
cl()
write('function main\nWpisz zup by zdalnie uruchomic program\nWpisz mftp by przeslac plik\n')
groch=io.read()
if groch=="zup" then
zup()
elseif groch=="mftp" then
menu2()
else
main()
end

function menu()
rednet.open(side)
cl()
write('Podaj id serwera: ')
idserwer=io.read()
idserwer=tonumber(idserwer)
cl()
write('Podaj kod: ')
kod=io.read()
cl()
write('Nazwiazywanie polaczenia')
rednet.send(serwerid,"mFTP")
id, out1=rednet.receive(10)
if out1==nil then
  write('\n Blad, nie mozna nawiazac polaczenia\n z serwerem.')
elseif out1=="mFTP" then
  sleep(2)
  rednet.send(serwerid,kod)
  id, our1 = rednet.receive(10)
  if our1==nil then
   print('Blad utracono polaczenie z serwerem')
  elseif our1=="OK" then
   write('\n Polaczono')
   sleep(2)
   main()
  end
end
end

function menu2()
  cl() write('Witaj w wersji 3.2')
  write('\nWpisz wyslij, by wyslac pliki ')
  write('\nWpisz exit, by wyjsc ')
  out2=io.read()
  cl()
  if out2==nil then
   print('Musisz wpisac komende')
   sleep(4)
   menu2()
  elseif out2=="wyslij" then
   wyslij()
  elseif out2=="exit" then
   os.reboot()
  else
   print('Nie znana komenda')
   sleep(4)
   menu2()
  end
end

function wyslij()
   write('Podaj nazwe pliku ktory chcesz wyslac\n')
   x3=io.read()
   sleep(1) cl()
   write('Podaj nazwe pod jaka zapisze sie plik\n')
   x4=io.read()
   if x3==nil or x4==nil then
	print('Blad. Nie podales nazwy pliku, lub nazwy jak bedzie sie nazywal')
	menu2()
   end
   rednet.send(serwerid, "mFTPwyslij"..kod)
   cl() write('Prosze czekac...')
   idl,in3=rednet.receive(10)
   print('odebralo')
   if in3==nil then
	write('Blad brak odpowiedzi od serwera')
	sleep(3)
	menu2()
   elseif in3 == "OK" then
	print('elseif')
	sleep(2)
	rednet.send(serwerid, x4) print('redsend')
	id,in4=rednet.receive(10) print('redreceive')
	if in4 == "OK" then
	 sleep(2) print('drugie if')
	 cl() write("Wysylanie pliku")
	 file=fs.open('/'..fs.getName(x3),'r')
	 rednet.send(serwerid,file.readAll())
	 file.close()
	 cl()
	 print("Wyslano")
	 sleep(4)
	end
	menu2()
   end
end	

function zup()
cl()
write('function zup\nPodaj nazwe programu, ktory chcesz\n uruchomic: ')
program=io.read()
cl()
rednet.send(serwerid,"mFTPzup"..kod)
id, zupres=rednet.receive(10)
if zupres==nil then
err()
elseif zupres=="OK" then
sleep(3)
rednet.send(serwerid,program)
end
end
  
cl()
sleep(3)
menu()


It's client. The server works properly so I have no reason to paste it here.
djblocksaway #2
Posted 05 May 2012 - 04:54 PM
hmm does it always print 13 or does it vary and did you code this on a Minecraft server?
Mazi30 #3
Posted 05 May 2012 - 05:01 PM
Yes it always print 13 and yes I code this on server.
Mazi30 #4
Posted 05 May 2012 - 05:23 PM
Well I restarted serwer and it's working somehow. Anyway thanks for help :)/>/>