Author Topic: coroutine.yield() query  (Read 3724 times)

Mihhaelo

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 67
coroutine.yield() query
« on: July 13, 2010, 05:02:16 AM »
After a few hours of trying to fix a chuggy map, i read some of the lua documentation and ended up adding lots of these to my code and alas, the map is no longer chuggy!

I was wondering how often i should use this? Where am i meant to be using this command? Is it possible to use it "too" much?

Edit: Just thought i'd add that it's now taking three seconds to go through my rather short code  :o

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: coroutine.yield() query
« Reply #1 on: July 13, 2010, 05:57:11 AM »
Anywhere you have a bunch of lua code that will take time to execute. The main game stops executing each frame to do Lua stuff, and it stays in the Lua code until it yields. So if you have an intensive loop, for example, or iterate over a lot of objects, then you may find it ends up staying inside the Lua code for a while. That'd be the right place for a yield.