However no matter how hard I try, when I try to make a loop to keep attacking I eventually get the error 'too long without yielding' is there a way to resolve this?
My code is below
local totalloot
totalloot = 0
local function updateterm()
term.clear()
print("----Dav's Mob Grinder Turtle----")
write("Total Items Looted: ")
write(totalloot)
print("--------------------------------")
print("")
print("")
print("Status:")
end
updateterm()
print("Mob grinder ready")
while true do
while redstone.getInput("left") == false do
turtle.attack()
for i=1,16,1 do
if turtle.getItemCount(i) > 0 then
totalloot = totalloot + turtle.getItemCount(i)
turtle.select(i)
turtle.dropDown()
updateterm()
print("Waiting for mob to spawn..")
end
end
sleep(2)
end
end
*EDIT* I see where my problem is now. It's not the turtle running that's the problem, it's when it's not running. If I have a redstone signal on (which tells the turtle to do nothing at the "while redstone.getInput("left") == false do" line) the turtle cycles on the false line over and over again rapidly and that's what makes it throw that error.
I can't work out in my head how to make it wait for a os pull event for the lever to be turned off, but while it's off continue it's loop on it's marry way until the redstone signal starts again. Any suggestions?












