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

help with stripmining program.

Started by subzero22, 11 January 2014 - 02:13 PM
subzero22 #1
Posted 11 January 2014 - 03:13 PM
Ok I need a little debugging help. I can't figure out the problem as it worked for me when i tested it but for my friend it just did one long strip. I even tried putting in the same commands that I know he put in but the others I can't remember.

Here's the program. http://pastebin.com/U3WQCpDr

Here's what he put
length 3
width I forgot what he put for width.
strips 3
right or left he put right
chest was no
torches yes
torch length was 6

For some reason when he did this at first for the first 12 blocks it didn't put any torches I'm thinking cause of the protectiont that was on the server as for some odd reason turtles can dig but not place stuff in protections. But the main problem was the turtle kept going strait and didn't turn at all. I went like 60 blocks strait before we broke it.

Now when on my turtle I tested the code It worked fine and as intended on the same server.. So I'm wondering what could have caused this?
surferpup #2
Posted 12 January 2014 - 04:38 AM
I think I understand your question. Basically, it behaved weird for you one time and now it works. Specifically, you indicate that it dug for "like 60 blocks strait before we broke it." You mention the turtle "kept going strait and didn't turn at all." You surmise that the reason it did not place torches was "cause of the protectiont that was on the server."

Ok. Well, in looking over the code, there is error recovery for turtle up, down, forward and back movement. However, for place and turning functions, there is no error recovery. For example, here is the turn function:


function turn()
  if left == "left" then
	turtle.turnLeft()
	for i=1,w do
	  strip()
	end
	turtle.turnLeft()
	left = "right"
  else
	turtle.turnRight()
	for i=1,w do
	  strip()
	end
	turtle.turnRight()
	left = "left"
  end
end

There is no checking to see if the turtle succeeded in turning left.

Without duplicating your exact conditions (which you seem to have difficulty doing), I would start with carefully looking over code responsible for the turn and place movements of the turtle.
CometWolf #3
Posted 12 January 2014 - 05:53 AM
Provided you actually call the function, there's no way a turtle.turn can fail…
surferpup #4
Posted 12 January 2014 - 12:26 PM
Hmm. I try and check to make sure everything succeeds with turtles. I am still working on recovery routines for failed turtle place commands (usually because something is in their way). I just assume if they are going to return success or failure info, the command can fail. You are probably right. I was just trying to understand the post and provide something of use.
subzero22 #5
Posted 12 January 2014 - 12:45 PM
I guess it was just a one time bug as I still can't reproduce it. I am wondering how a turtle can fail at turning as it's not like something can be in their way to turn. It's not like placing a block or trying to move forward. I guess I could do a while not turtle.turn in there but I never saw the point of it.

On a side note how would I go about making it so the turtle can detect resources without having blocks in it's inv to compare to? Like is there a way to grab a blocks from a chest, check them then compare then without keeping them in it's inv? Or is there a way to compare from uuid?
CometWolf #6
Posted 12 January 2014 - 01:30 PM
I think some mod peripherals can do stuff like that. The way i do it however, is i compare to the blocks i don't want as normally there's less of them. Like say you want a turtle to auto mine ores, you compare with stone,dirt,gravel and maybe sand. If it's not any of those, it's an ore.
subzero22 #7
Posted 12 January 2014 - 08:38 PM
ah ok I wasn't sure if uuid was part of computercraft or the mods. thanks for the help everyone.
Buho #8
Posted 13 January 2014 - 12:06 PM
Provided you actually call the function, there's no way a turtle.turn can fail…
One of my mining programs writes the facing direction to file right before turning. I've had the chunk unload between those two lines, which counts as a fail in my book.
CometWolf #9
Posted 13 January 2014 - 12:19 PM
Provided you actually call the function, there's no way a turtle.turn can fail…
Please do note the bolded part, that you yourself qouted.