Code is below, thanks for any help and/or fixes
m=peripheral.wrap("right")
m.setAutoCollect()
while true do
if (m.getLevels()>=30) then
turtle.select(1)
turtle.transferTo(16,1)
turtle.select(16)
m.enchant(30)
turtle.drop()
end
end
m=peripheral.wrap("right")
m.setAutoCollect()
while true do
if (m.getLevels()>=30) then
turtle.select(1)
turtle.transferTo(16,1)
turtle.select(16)
m.enchant(30)
turtle.drop()
end
end
Could you give an example of something that would yield?Split into new topic.
When your turtle has fewer than 30 levels, it just busy loops, doing nothing and checking the levels. Outside the if statement, add a sleep(10) or something so that it actually yields.
while true do
if (m.getLevels()>=30) then
-- existing code
else
sleep(10)
end
end
that way when the level is greater than 30 it just sits there and waitsAh okay, got that sorted out.he did give an example….
but here is some morebasically he just means have the turtle sleep at the end of the while loop… i would probs recommend to put
- sleep
- os.pullEvent
- os.pullEventRaw
- turtle functions that involve the turtle moving
that way when the level is greater than 30 it just sits there and waitswhile true do if (m.getLevels()>=30) then -- existing code else sleep(10) end end
while true do
turtle.attack()
end
Neither turtle.attack nor sleep(0) appear to yield, as I just got the same error withI cannot remember 100%, but I'm pretty sure that turtle.attack will yield, so it won't error out, just constantly attack and probs cause some lag.
as for programs that you don't want to wait, you can use pull event loops or just simply sleep(0) depending on which is appropriate for the given program
while true do
turtle.attack()
sleep(0)
end
Neither turtle.attack nor sleep(0) appear to yield, as I just got the same error withI cannot remember 100%, but I'm pretty sure that turtle.attack will yield, so it won't error out, just constantly attack and probs cause some lag.
as for programs that you don't want to wait, you can use pull event loops or just simply sleep(0) depending on which is appropriate for the given programwhile true do turtle.attack() sleep(0) end
That is the whole and only code on the entire turtle besides the romNeither turtle.attack nor sleep(0) appear to yield, as I just got the same error withI cannot remember 100%, but I'm pretty sure that turtle.attack will yield, so it won't error out, just constantly attack and probs cause some lag.
as for programs that you don't want to wait, you can use pull event loops or just simply sleep(0) depending on which is appropriate for the given programwhile true do turtle.attack() sleep(0) end
Is that the whole and only code you're using? I suspect that it isn't, if you're still getting that error.