-
Notifications
You must be signed in to change notification settings - Fork 0
Lua API
The main features of YALP are concentrated in the Lua API. It offers 3 packages for various purposes, and also a couple of new functions in standard Lua packages.
By default, the additional packages are not loaded into the global environment, and are to be used via the standard Lua package system, loaded by their name (from the preload table):
local interop = require "interop"
interop.native.print("Hello world!")This has the advantage of better code isolation, slighly faster access (local vs. global variable), and lazy loading. Some packages like interop may also perform a lot of actions in their loading procedure.
YALP provides these new packages:
print(...)print behaves the same as in standard Lua, but uses the logprintf plugin API function.
take(num, func, ...)Calls func(...), expecting num results. Since some functions in the Lua API are optimized based on the number of return values, it is necessary to provide a method to specify this number explicitly. If the call returns less than num results, the rest is filled with nils.
bind(func, ...)Binds a function to a variable number of fixed arguments, and returns a new function which, when called, passes the original arguments as well as the new ones to func.
async(func, ...)Creates a new coroutine and runs func within it, passing all arguments to the function. The function is expected to yield values reg, ..., and async calls reg(cont, ...), where cont is a continuation function that resumes the coroutine.
table.clear(t)Removes all elements from t.