Posted 27 January 2013 - 09:06 PM
title: Question how to make turtle return when done
Hello all, so i am quite new at this whole computer craft and as such I am unable to make my turtle come back to where it started when it is done
so i am getting an error message saying "bios:338:[ string "ttr" ] :93 :<'eof>' expeced and im not sure how to solve this
and incite on the matter would be wonderful
Cheers
Hello all, so i am quite new at this whole computer craft and as such I am unable to make my turtle come back to where it started when it is done
local tArgs = { ... }
if #tArgs ~= 1 then
print( "Usage: torchedtunnel <length>" )
return
end
local length = tonumber( tArgs[1] )
if length < 1 then
print( "Tunnel length must be positive" )
return
end
local function tryRefuel()
if turtle.getFuelLevel() == 0 then
turtle.select(1)
turtle.refuel(1)
end
end
local function tryDig()
while turtle.detect() == true do
turtle.dig()
sleep(0.5)
end
end
local function tryDigUp()
while turtle.detectUp() == true do
turtle.digUp()
sleep(0.5)
end
end
local function tryUp()
tryDigUp()
tryRefuel()
turtle.up()
end
local function tryDown()
while turtle.detectDown() == true do
turtle.digDown()
sleep(0.5)
end
tryRefuel()
turtle.down()
end
local function tryForward()
tryDig()
tryRefuel()
turtle.forward()
end
local function makeBridge()
if turtle.detectDown() == false then
turtle.select(2)
turtle.placeDown()
end
end
local count = 1
print( "Tunnelling..." )
for i = 1, length do
tryForward()
makeBridge()
tryDigUp()
turtle.turnLeft()
tryDig()
tryUp()
tryDig()
if count % 8 == 0 then
turtle.select(3)
turtle.place()
end
turtle.turnRight()
turtle.turnRight()
tryDig()
tryDown()
tryDig()
turtle.turnLeft()
count = count + 1
end
print( "Returning to start..." )
-- Return to where we started
turtle.select(3)
turtle.place()
turtle.turnLeft()
turtle.turnLeft()
turtle.forward(length)
end
so i am getting an error message saying "bios:338:[ string "ttr" ] :93 :<'eof>' expeced and im not sure how to solve this
and incite on the matter would be wonderful
Cheers