while true do
while redstone.getInput("back") do
turtle.attack()
sleep(.1)
end
sleep(.5)
end
while true do
while turtle.detectDown() ~= true do
turtle.attack()
end
end
Here's a nice one for you. I use this for it's easy toggle-ability with a piston.
Code:while true do while turtle.detectDown() ~= true do turtle.attack() end end
Turtle will look for a block underneath it. If a block is present it won't attack. If block isn't present, it will attack if an entity's in range.
Yeah from what I can gather the turtle.attack() contain its own yield. But if the if the while condition is not met? Does the while condition contain a yield too? Nevertheless you should add a sleep() in the outer loop, if for nothing else to prevent spending a lot of resources on just checking condition for that while loop. You really don't need to look for a block under the turtle as often as the processor can handle. every couple of seconds should be plenty.That script will die due to never yielding, as every branch of the program needs a sleep, doesn't really matter how long, else the CC OS will kill the program for not yielding. If not someone could write a program that does
while true do
I=1
I=2
End
That simple little program would tie up CC utterly and totally without safeguards.
Sent from my iPad using Tapatalk