Posted 08 August 2013 - 09:36 PM
I am fairly new to Lua and am having trouble with finding a way to stop my turtles at a certain level.
local fuelSlot = 16
local fuelToConsume = 1
local fuelNeeded = 2
local lastSlot = 14
local blockSlot = 1
local fuel = turtle.getFuelLevel()
while turtle.getItemCount(1) <= 10 do
print "Please put atleast 10 cobble/dirt in slot 1. Also put atleast 1 GRAVEL in slot 2, if you do not do so the turtle might bug and dig straigt down. Hit any key when done."
os.pullEvent("char")
end
function gravelCheck()
turtle.select(2)
if turtle.compare(2) == true then
turtle.dig()
gravelCheck2()
end
end
function gravelCheck2()
turtle.select(2)
if turtle.compare(2) == true then
turtle.dig()
gravelCheck()
end
end
function checkFuel()
if fuel < fuelNeeded then
turtle.select(fuelSlot)
print"Getting Fuel"
turtle.refuel(fuelToConsume)
return false
end
if fuel >= fuelNeeded then
turtle.select(fuelSlot)
print"Already Fueled"
return true
end
end
function digDown()
if fuel >= fuelNeeded then
turtle.select(blockSlot)
turtle.digDown()
turtle.down()
turtle.placeDown()
end
end
function digUp()
if fuel >= fuelNeeded then
turtle.up()
turtle.digUp()
turtle.up()
turtle.digUp()
turtle.down()
turtle.down()
return true
end
end
function dig()
if digUp() == true then
turtle.dig()
turtle.forward()
end
end
function mineDown()
checkFuel()
if fuel >= fuelNeeded then
digDown()
digUp()
dig()
end
end
while turtle.getItemCount(1) >= 10 do
gravelCheck()
gravelCheck2()
mineDown()
end
Thats my current Mining Turtle code. I would like it to stop on level 6. Thank you in advanced to whoever can help.