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

first program, tunnel empty space

Started by blackbetty, 16 February 2015 - 05:25 PM
blackbetty #1
Posted 16 February 2015 - 06:25 PM
this is my first script. i have very little programming experience, mostly html. i want it to dig a 3x3 tunnel. so far it works pretty great. until it encounters an empty block, then it keeps going in that direction messing up its pattern. any suggestions?


local run = 0
term.write("Distance? ")
run = read() / 2
function digAll()
   while turtle.detect() do
	  turtle.dig()
	  sleep(0.5)
   end
end
function digForward()
   digAll()
   turtle.forward()
   turtle.digUp()
   turtle.digDown()
end
function layerA()
   digForward()
   turtle.turnLeft()
   digForward()
   turtle.forward()
   digForward()
   turtle.turnRight()
end
function layerB()
   digForward()
   turtle.turnRight()
   digForward()
   turtle.forward()
   digForward()
   turtle.turnLeft()
end
for i = 1, run do
   layerA()
   layerB()
end

digAll() is for gravel/sand
distance is divided in half because it makes two passes. left to right, then right to left. this is to minimize movement as much as possible to conserve fuel.
blackbetty #2
Posted 16 February 2015 - 08:15 PM
nevermind, found the problem. i had some extra forwards in the layer functions. thanks anyway, gang. mods can delete
Edited on 16 February 2015 - 09:01 PM
luckyboy6 #3
Posted 17 February 2015 - 12:42 AM
I want to do this and make it wireless so I can see it on a monitor. Can you show the debugged version of this or make me be able to do "pastebin get" for your program. thx :)/>
blackbetty #4
Posted 17 February 2015 - 06:32 AM
here you go cECcuPCs
i added some torch placement too. if theres torches in slot 16 it will place one down every 10 blocks.
the turtle's starting position is
OOO
OOX
OOO
luckyboy6 #5
Posted 18 February 2015 - 12:40 AM
thx