Posted 04 January 2013 - 12:42 PM
                Hey,
So I am writing a script so the turtle will dig a 2x1 shaft a specified amount of blocks placing a torch every 9 blocks. I got that part working fine but recently I want to the turtle to also turn around and go back to where it began. I am trying to do this all with counting of numbers.
Here is the code
http://pastebin.com/1vJKHK7h
The prints are in there for a debug option
-Bird
                
            So I am writing a script so the turtle will dig a 2x1 shaft a specified amount of blocks placing a torch every 9 blocks. I got that part working fine but recently I want to the turtle to also turn around and go back to where it began. I am trying to do this all with counting of numbers.
Here is the code
http://pastebin.com/1vJKHK7h
Spoiler
--Variables
local tArgs = { ... }
local togo = tonumber (tArgs[1])
local num = 0
local count = tonumber (tArgs[1])
--Function
function tfuel(amount)
  local fuelLevel = turtle.getFuelLevel()
  if fuelLevel < 50 then
    turtle.select(16)
    turtle.refuel(amount)
    turtle.select(1)
  end
end
function torch()
  if num == 10 then
    turtle.select(15)
    turtle.turnRight()
    turtle.turnRight()
    turtle.forward()
    turtle.placeUp()
    turtle.turnRight()
    turtle.turnRight()
    turtle.forward()
    turtle.select(1)
    num = 0
  end
end
function detect()
turtle.detect()
    if result == true then
	  turtle.dig()
    end
  end
function layer()
  turtle.dig()
  os.sleep(.25)
  detect()
  turtle.up()
  turtle.dig()
  os.sleep(.25)
  detect()
  turtle.down()
  turtle.forward()
end
function turnAround()
  turtle.turnRight()
  turtle.turnRight()
end
--Main Script
print(tArgs[1])
print(togo)
  if togo == (tArgs[1]) then
    repeat
	  tfuel(1)
	  layer()
	  torch()
	  num = num + 1
	  togo = togo - 1
    until togo == 0
  else
    turnAround()
    repeat
	  tfuel(1)
	  turtle.forward()
	  togo = togo + 1
    until togo == (tArgs[1])
  end
The prints are in there for a debug option
-Bird