Posted 16 December 2012 - 07:22 PM
So I just wrote this scrip that is supposed to dig a path through Mountains, it works fine, until it comes to repeat, it will dig, dig up, go up, dig up again, then if there's no block it'll go down, go forward, and dig, but there it will just terminate the program, Please help
-Popretmaster
[EDIT] the sleep(5) in the middle was just because I almost lost my turtle before due to a bug where it traveled up forever, in this version it's fixed, the repeat error is not
-Popretmaster
--Moutain Miner by Popretmaster
local goneUp=0
local opStatus=0
local randomVarPlaceHolder=0
local repeatEndVar=2
local detectBlock = turtle.detectUp()
local tArgs = {...}
if #tArgs ~= 1 then
print("Wrong Usage")
return
end
local distance = tonumber(tArgs[1])
repeat
distance = distance - 1
if turtle.detect() then
turtle.dig()
sleep(1)
if detectBlock == true then
repeat
turtle.digUp()
turtle.up()
detectBlock = turtle.detectUp()
sleep(5)
goneUp=goneUp+1
until detectBlock == false
sleep(1)
if detectBlock == false then
repeat
turtle.down()
goneUp=goneUp-1
until goneUp == 0
repeatEndVar = 0
opStatus = 2
sleep(1)
end
end
end
if opStatus == 2 then
turtle.forward()
opStatus = 0
end
until distance == 0
[EDIT] the sleep(5) in the middle was just because I almost lost my turtle before due to a bug where it traveled up forever, in this version it's fixed, the repeat error is not