120 posts
Posted 21 December 2012 - 04:15 PM
any one know of a good tutorial on coroutines?
also with coroutines , is their any limit to how many things are being listened for with os.pullEvent()?
145 posts
Location
the vast cosmos of my mind; binary!
Posted 21 December 2012 - 06:56 PM
REALLY don't use coroutines unless use ABOSLUTELY can't useing anything ELSE ok.
alot can go wrong with coroutines. this is from experiance just warning you
1054 posts
Posted 21 December 2012 - 09:13 PM
any one know of a good tutorial on coroutines?
also with coroutines , is their any limit to how many things are being listened for with os.pullEvent()?
1.
http://lua-users.org/wiki/CoroutinesTutorial2. no, you can listen to os.pullEvent as much as you want (not entirely sure what you mean though)
3. maybe this is what you want to know: I seem to remember that a computer can have a maximum of 50 coroutines. I don't remember the source though.
4. you can use the parallel API from CC in a lot of cases where you want to use coroutines:
http://www.computercraft.info/forums2/index.php?/topic/2030-tutorial-parallel-api
120 posts
Posted 21 December 2012 - 09:50 PM
on the pull event thing, i'm wondering about multiple ones run all at once
1054 posts
Posted 21 December 2012 - 09:52 PM
on the pull event thing, i'm wondering about multiple ones run all at once
That's no problem, they'll all be able to pull each event.
2005 posts
Posted 21 December 2012 - 11:51 PM
That is to say, you don't pull multiple events, you just pull the next event, whatever it is, by not specifying an event type:
t_event = {os.pullEvent()}
Then you use an if/elseif block (or function table) to react to each event type differently.
120 posts
Posted 22 December 2012 - 04:47 PM
yes! =D ty
now to make my own os … lol
1548 posts
Location
That dark shadow under your bed...
Posted 23 December 2012 - 08:02 AM
there is actually no limit on coroutines… the thing is that they are not running simultaneously but rather running small parts one by one, if you add enough coroutines eventually things will start running slow as 50 small snippets of code still take a while to run, I would never advise anyone to avoid coroutines, I think they are the second most useful thing in Lua and should be used accordingly