The very first time you resume a coroutine, it begins working the human anatomy. The principles val1 , A·A·A· tend to be passed just like the arguments for the body purpose. If coroutine enjoys yielded, resume restarts they; the prices val1 , A·A·A· include passed as the is a result of the produce.
If coroutine works without the mistakes, resume comes back real plus any standards passed to produce (if the coroutine yields) or any prices returned from the human anatomy function (if the coroutine terminates). If there’s any mistake, resume profits untrue as well as the error information.
coroutine.status (co)
Profits the updates of coroutine co , as a string: «running» , if coroutine are operating (that is, it also known as condition ); «dangling» , if the coroutine is dangling in a call to produce , or if it’s perhaps not going working yet; «normal» when the coroutine is productive yet not working (that is, it’s got started again another coroutine); and «dead» in the event the coroutine provides complete their looks work, or if it’s got ended with an error.
coroutine.wrap (f)
Brings a new coroutine, with human body f . f should be a Lua work. Profits a function that resumes the coroutine each and every time its also known as. Any arguments passed with the features behave as the additional arguments to resume . Profits the exact same beliefs returned by resume , except the very first boolean. In case there are error, propagates the mistake.
coroutine.yield (A·A·A·)
Suspends the performance of the contacting coroutine. The coroutine should not be operating a-c purpose, a metamethod, or an iterator. Any arguments to give are passed away as additional brings about resume .
5.3 Segments
The plan collection supplies standard services for loading and building modules in Lua. It exports two of its functions immediately when you look at the global environment: require and module . The rest try shipped in a table package .
module (label [, A·A·A·])
Brings a module. When there is a desk in package.loaded[name] , this desk may be the module. If not, when there is a major international dining table t using offered term, this dining table will be the component. Usually produces an innovative new dining table t and kits it the worth of the global term in addition to value of plan.loaded[name] . This features in addition initializes t._NAME making use of the provided identity, t._M making use of module ( t alone), and t._PACKAGE with all the plan label (the full module title minus latest component; read below). Eventually, module units t given that new surroundings associated with latest features and also the brand new worth of bundle.loaded[name] , so that require profits t .
If name is a compound term (that’s, one with hardware split up by dots), module produces (or reuses, should they currently are present) dining tables each element. By way of example, if name’s a.b.c , then module storage the module dining table in area c of industry b of worldwide a .
This work can get optional solutions following the module label, where each option is a purpose to get applied over the component.
need (modname)
Loads the considering module. The function starts by considering the plan.loaded desk to ascertain whether modname is already filled. In case it is, subsequently call for profits the value retained at bundle.loaded[modname] . Or else, they attempts to look for a loader for module.
Discover a loader, require are led from the package.loaders variety. By altering this array, we are able to transform just how require actively seeks a module. These reason is dependent on the standard setup for bundle.loaders .
Initially require queries package.preload[modname] . Whether it provides a value, this importance (which ought to feel a function) may be the loader. Or else need pursuit of a Lua loader making use of the course stored in bundle.path . If that in addition fails, they searches for a-c loader making use of the route stored in plan.cpath . If that also fails, they attempts an all-in-one loader (see bundle.loaders ).