Posted 30 April 2014 - 01:20 PM
                (NOTE: i posted this again after i started this topic because i wasn't sure this one was send propperly, please delete the other one if it comes through for aproval, thank you!)
Hi there, i am writing a quarrying program (with the help of BSGSamuel's tutorial on youtube) that get's it's coordinates over rednet from a server. I am trying to write a feature that has the turtle send out a jobrequest again (using a broadcast) if it didn't get a reply in time, and gives up after several attempts.
However the turtle keeps "crashing" after a certain piece of code has been executed. No error code just a screen turning black.
Here's the code as it is (for troubleshooting purpose it's slightly modefied to work standallone, the error is still there though)
what it SHOUD do:
1: send out a broadcast containing a string value ("JOBREQ")
2: any computer listening for the string value from 1 would reply and say wheater it got a quarrying job available ("YES" or "NO")
3: the turtle listens for several seconds for a reply. if it does not get a reply in time it will send the broadcast again
4: turtle will try 6 times before giving up, changing jobAv to false and thus ending the function
5: if the reply is "YES" it will start listening for the X Y Z coordinates and desired orientation respectively
6: a quarrying function will be executed
7: turtle will repeat untill it get's no more reply or a "NO" for an answere, both will end the function
hope some one can help me out with this! :)/>
                
                    Hi there, i am writing a quarrying program (with the help of BSGSamuel's tutorial on youtube) that get's it's coordinates over rednet from a server. I am trying to write a feature that has the turtle send out a jobrequest again (using a broadcast) if it didn't get a reply in time, and gives up after several attempts.
However the turtle keeps "crashing" after a certain piece of code has been executed. No error code just a screen turning black.
Here's the code as it is (for troubleshooting purpose it's slightly modefied to work standallone, the error is still there though)
xDes = 0
yDes = 0
zDes = 0
orid = 0
t = 1
jobAv = true
function getJob()
  while jobAv do
	while  t < 6 do
	rednet.broadcast("JOBREQ")
	print("Jobrequest send, awaiting response from job server..")
	ID,Mess,Diss = rednet.receive(3)
		if ID == nil then
		print("request timeout "..t)
		t = t + 1
		else
		t = 6
		end
  end
  end
--no matter if the turtle got a reply or not, the turtle "crashes" after this point.
  
	if Mess == "YES" then
	print("reply received from: "..ID)	  
  
	ID,Mess,Diss = rednet.receive()
	xDes = Mess
	ID,Mess,Diss = rednet.receive()
	yDes = Mess
  
	ID,Mess,Diss = rednet.receive()
	zDes = Mess
  
	ID,Mess,Diss = rednet.receive()
	orid = Mess
	print("order received for X: "..xDes.." Y: "..yDes.." Z: "..zDes)
-- in the actual code a quarrying function would start running here using the just received coordinates
  
	elseif Mess == "NO" then
	print("no jobs available")
	  jobAv = false
  
	else
	print("no jobs available")
	  jobAv = false
  
	end
	print("FUNCTION COMPLETE")
  end
  rednet.open("right")  
  getJob()
what it SHOUD do:
1: send out a broadcast containing a string value ("JOBREQ")
2: any computer listening for the string value from 1 would reply and say wheater it got a quarrying job available ("YES" or "NO")
3: the turtle listens for several seconds for a reply. if it does not get a reply in time it will send the broadcast again
4: turtle will try 6 times before giving up, changing jobAv to false and thus ending the function
5: if the reply is "YES" it will start listening for the X Y Z coordinates and desired orientation respectively
6: a quarrying function will be executed
7: turtle will repeat untill it get's no more reply or a "NO" for an answere, both will end the function
hope some one can help me out with this! :)/>
Edited on 30 April 2014 - 12:58 PM
                
             
         
                