Posted 18 August 2016 - 10:45 AM
Hello code-dwellers, I'd like get some help with my mining program. It's not a usual program, because it's made to mine out the Twilight Forest hollow hills. The concept is: the turtle clears the area layer by layer (16x16) then proceeds to the next level (16 cube high). It's quite slow for my liking, so I made new function to speed it up a litlle bit. My version sadly doesn't include the inspect commands (version 1.5). The process is, as the turtle dig the layers, it's scanning the blocks above it and if it's not dirt,stone or marble it excavate the ore pillar then return to the original layer and resume the spelunking. The problem is I don't know how to make a while loop with multiple conditions, meaning the turtle should descend whether it reaches dirt marble or stone. Any help appreciated:
Cthonia
Cthonia
function digv()
if not turtle.detectDown() then
turtle.select(13)
turtle.placeDown()
end
while not turtle.compareUp() do
turtle.select(12)
while not turtle.compareUp() do
turtle.select(14)
while not turtle.compareUp() do
turtle.digUp()
turtle.up()
end
while not turtle.detectDown() do
turtle.down()
end
turtle.digDown()
end
function strip()
for i = 1,16 do
turtle.dig()
turtle.forward()
turtle.select(12)
if not turtle.compareUp() then
turtle.select(13)
if not turtle.compareUp() then
turtle.select(14)
if not turtle.compare() then
if turtle.detectUp() then
digv()
end
end
end
end
end
end
function fuel()
if turtle.getFuelLevel() < 80 then
turtle.select(16)
turtle.refuel(1)
end
end
function turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
end
function turnRight()
turtle.dig()
turtle.forward()
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnRight()
end
function dump()
turtle.select(15)
turtle.dig()
turtle.place()
for i = 1,11 do
turtle.select(i)
turtle.drop()
end
turtle.select(15)
turtle.dig()
end
function layer()
fuel()
strip()
turnLeft()
strip()
turnRight()
strip()
fuel()
dump()
turnLeft()
strip()
turnRight()
strip()
turnLeft()
strip()
fuel()
dump()
turnRight()
strip()
turnLeft()
strip()
turnRight()
strip()
fuel()
dump()
turnLeft()
strip()
turnRight()
strip()
turnLeft()
strip()
fuel()
dump()
turnRight()
strip()
turnLeft()
strip()
turnRight()
strip()
fuel()
dump()
turnLeft()
strip()
turtle.forward()
turtle.turnLeft()
for i = 1,15 do
turtle.dig()
turtle.forward()
end
turtle.turnLeft()
fuel()
dump()
turtle.digUp()
turtle.up()
end
function cube()
for i = 1,16 do
layer()
end
end
cube()