Jump to content




"too long without yielding"(Solved)


  • You cannot reply to this topic
11 replies to this topic

#1 Apfeldstrudel

  • Members
  • 161 posts

Posted 27 May 2013 - 12: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?

#2 Bubba

    Use Code Tags!

  • Moderators
  • 1,142 posts
  • LocationRHIT

Posted 27 May 2013 - 12: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?

#3 Apfeldstrudel

  • Members
  • 161 posts

Posted 27 May 2013 - 03:03 PM

Pastebin:http://pastebin.com/6w6unec9
Im playing a singleplayer world through the launcher, might have modified the rem through there though

#4 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 28 May 2013 - 01: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

#5 Apfeldstrudel

  • Members
  • 161 posts

Posted 28 May 2013 - 09:08 AM

In what while loop? i have a lot of them

#6 tonkku107

  • Members
  • 140 posts
  • LocationFinland

Posted 28 May 2013 - 12:47 PM

Try adding sleep() somewhere

#7 Apfeldstrudel

  • Members
  • 161 posts

Posted 28 May 2013 - 01:03 PM

I dont think a sleep will work, nor do i want to slow my turtle

#8 tonkku107

  • Members
  • 140 posts
  • LocationFinland

Posted 28 May 2013 - 01:04 PM

View PostXyexs, on 28 May 2013 - 01:03 PM, said:

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?

#9 Apfeldstrudel

  • Members
  • 161 posts

Posted 28 May 2013 - 01:13 PM

Yeah but if i put 0.2 sleep its gonna be 0.2 seconds slower EVERY SINGLE BLOCK it mines

#10 Apfeldstrudel

  • Members
  • 161 posts

Posted 28 May 2013 - 01:21 PM

View Posttonkku107, on 28 May 2013 - 01:04 PM, said:

View PostXyexs, on 28 May 2013 - 01:03 PM, said:

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

#11 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 28 May 2013 - 01:25 PM

use:

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

This yields and is quicker than sleep(0)

#12 Apfeldstrudel

  • Members
  • 161 posts

Posted 28 May 2013 - 01:30 PM

View PostEngineer, on 28 May 2013 - 01:25 PM, said:

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users