This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Apfeldstrudel's profile picture

"too long without yielding"(Solved)

Started by Apfeldstrudel, 27 May 2013 - 11:29 AM
Apfeldstrudel #1
Posted 27 May 2013 - 01:29 PM
i have made a mining turtle. its worked fine for a couple of days now but now i got the error : "*see title*"

Note that i call the function many times and it doesnt break dorecly

seems to have got stuck on the following function

function save()
	    s = fs.open("coords","w")
	    s.writeLine(size) <--- here is where it breaks
	    s.writeLine(depth)
	    s.writeLine(x)
	    s.writeLine(y)
	    s.writeLine(z)
	    s.writeLine(facing)
	    s.close()
end

googled and it might be lag? Confirm? Way around it?
Bubba #2
Posted 27 May 2013 - 01:39 PM
That's weird. Your code works perfectly fine for me and should not be forcing a "too long without yielding" error. Can you provide the full code on pastebin so that we can check the rest for errors as well (it is unlikely that this particular issue would originate elsewhere, but still possible).

By chance are you playing on a server with modified ROMs or using a startup program that might change the behavior of opening files?
Apfeldstrudel #3
Posted 27 May 2013 - 04:03 PM
Pastebin:http://pastebin.com/6w6unec9
Im playing a singleplayer world through the launcher, might have modified the rem through there though
Engineer #4
Posted 28 May 2013 - 02:15 AM
Its very easy to fix, in theory.
In your while loop, you do this:

while var % 2 == 0 do
    --something
    var = read()
end
Make that var into this:

var = tonumber(read())

this should work because var is not a string anymore
Apfeldstrudel #5
Posted 28 May 2013 - 10:08 AM
In what while loop? i have a lot of them
tonkku107 #6
Posted 28 May 2013 - 01:47 PM
Try adding sleep() somewhere
Apfeldstrudel #7
Posted 28 May 2013 - 02:03 PM
I dont think a sleep will work, nor do i want to slow my turtle
tonkku107 #8
Posted 28 May 2013 - 02:04 PM
I dont think a sleep will work, nor do i want to slow my turtle
I got the error, and i added sleep(0.2)
worked
is there other ways?
Apfeldstrudel #9
Posted 28 May 2013 - 02:13 PM
Yeah but if i put 0.2 sleep its gonna be 0.2 seconds slower EVERY SINGLE BLOCK it mines
Apfeldstrudel #10
Posted 28 May 2013 - 02:21 PM
I dont think a sleep will work, nor do i want to slow my turtle
I got the error, and i added sleep(0.2)
worked
is there other ways?
I dont wanna slow my turtle..D; i call that function after every block mined
Engineer #11
Posted 28 May 2013 - 02:25 PM
use:

os.queueEvent("test")
coroutine.yield()

This yields and is quicker than sleep(0)
Apfeldstrudel #12
Posted 28 May 2013 - 02:30 PM
use:

os.queueEvent("test")
coroutine.yield()

This yields and is quicker than sleep(0)

In the save function? ill try
Edit: seems to work, ill be back for updates
Worked fine for a couple of days, officialy solved