I apologize in advance for my english translation, I'm french.
I use lua in computercraft to automate the mining. But, my turtle whose program worked very well before, stops if it meets a lava/flowing_lava/water/flowing_water source..
Inside my program, I have a lot of function to manage, for exemple, the fuel management, the tunnel, the collison with gravel, and .. the detection if the turtle meets a "block".
If the block is juste an air block, the turtle continues to advance, elseif the block isn't an air block, the turtle dig this block and doesn't move forward if there is still a block in front of her. The problem ? The four source which I quoted previously are considered as blocks, and the turtle can't move forward.
I try to fix this problem with multi condition into the if, but it's doesn't work, the turtle moves forward and dig in any direction..
So I think it's because my way of creating the if isn't good, may be the syntax (for concatenate many or into () ).
If you can help me, I would be very very grateful ..
(I don't know why the beginning of my function doesn't enter into the block of code :/ )
function blockDetection(position, justDetection) success, detectionBlock = nil block_name = ""
if position == "right" then
turtle.turnRight()
success, detectionBlock = turtle.inspect()
turtle.turnLeft()
if success then
block_name = detectionBlock.name
if justDetection == true and detectionBlock.name == "minecraft:air" then
block_name = true
elseif justDetection == true and detectionBlock.name ~= "minecraft:air" then
block_name = false
else
end
end
end
end
Aucun commentaire:
Enregistrer un commentaire