Hi guys/girls,
I play FTB Infinity and currently having a problem with my mining turtle code.
I hope someone can help me.
function DigForward(x)
--Grabe eine gerade Linie
--x lang
local BlockDetected, Block = turtle.inspect()
local CriticalBlockDetected = false;
for i=1, x do
if BlockDetected then
while Block.name == "minecraft:gravel" or Block.name == "minecraft:sand" do
turtle.dig()
sleep(0.9)
CriticalBlockDetected = true
BlockDetected, Block = turtle.inspect()
end
end
if CriticalBlockDetected ~= true then
turtle.dig()
end
turtle.forward()
turtle.digUp()
CriticalBlockDetected = false
end
end
What it should do: Dig a straight line x long. If it detects gravel or sand: Dig, wait for the blocks to fall down and go forward if none come down anymore.
What it actually does: Digs a line x long if it is not gravel or sand. If it is gravel or sand, it digs 5 times and stops.
I don't have a clue why the program does that, because code wise it shouldn't do that. It feels a bit like the for loop counts while the while loop does its thing.
(Why do i write it this complicated ? Because i want to speed up the digging and only wait 0.9 seconds if there is actual gravel or sand. Otherwise dig or just go forward if there is no block at all. )
Br Xhapan
I play FTB Infinity and currently having a problem with my mining turtle code.
I hope someone can help me.
function DigForward(x)
--Grabe eine gerade Linie
--x lang
local BlockDetected, Block = turtle.inspect()
local CriticalBlockDetected = false;
for i=1, x do
if BlockDetected then
while Block.name == "minecraft:gravel" or Block.name == "minecraft:sand" do
turtle.dig()
sleep(0.9)
CriticalBlockDetected = true
BlockDetected, Block = turtle.inspect()
end
end
if CriticalBlockDetected ~= true then
turtle.dig()
end
turtle.forward()
turtle.digUp()
CriticalBlockDetected = false
end
end
What it should do: Dig a straight line x long. If it detects gravel or sand: Dig, wait for the blocks to fall down and go forward if none come down anymore.
What it actually does: Digs a line x long if it is not gravel or sand. If it is gravel or sand, it digs 5 times and stops.
I don't have a clue why the program does that, because code wise it shouldn't do that. It feels a bit like the for loop counts while the while loop does its thing.
(Why do i write it this complicated ? Because i want to speed up the digging and only wait 0.9 seconds if there is actual gravel or sand. Otherwise dig or just go forward if there is no block at all. )
Br Xhapan