The problem occurs when mob/player is standing on a path of turtle against the wall or on the back edge of block to which turtle wants to move.
In normal conditions. Turtle attacks mob moving them away. Though in circumstances above it just stops and counts up the loop, at the end of which it decides that it has faced an un-diggable barier and decides to move to base (which it should do if a block in front is un-diggable)
Code that is responsible for moving the turtle
function tMineForward(whenmining) local isblocked = true local attempts = 0 local returnValue = "Mine" while isblocked == true do turtle.attack() turtle.dig() if turtle.detect() == false then isblocked = false else attempts = attempts + 1 end if attempts > tonumber(GetVariable("maxattempts")) then returnValue = "GoToEnd" isblocked = false end end if returnValue == "Mine" then if tMoveForward(whenmining) ~= "Continue" then returnValue = "GoToEnd" end end return returnValue end function tMoveForward(whenmining) local isBlocked = true local attempts = 0 local returnValue = "Continue" while isBlocked == true do turtle.attack() turtle.dig() if turtle.forward() == true then isBlocked = false SaveMovement(whenmining, "F") else attempts = attempts + 1 end if attempts > tonumber(GetVariable("maxattempts")) then returnValue = "GoToEnd" isblocked = false end end return returnValue end
My question: Is there a better way to move mobs in front or detect them?
My reason for having maxattempts variable is that the turtle can start mining on x levels below current one. So I wanted to have something that will handle falling gravel/sand and not make turtle stuck on bedrock.
Any help is greatly appreciated.
Thanks
PS. Just looked on the home page and attack range was increased in 1.51. Though I'm using FTB and it looks like this update doesn't come there for quite some time />