|create(f[, priority[, stack_size[, disable_powersave=false]]])||Creates a new task.|
|yield(duration)||Yields execution of this script to other tasks and event handlers (also from the same script).|
- create(f[, priority[, stack_size[, disable_powersave=false]]])
Creates a new task. It will begin executing when you return or call task.yield().
Tasks spawned from Lua can optionally run with powersaving disabled (so the camera won't turn off while running them) if you enable
task.create(my_func, nil, nil, true)).
- f function the function to run
- priority int DryOS task priority (0x1F = lowest priority; lower values = higher priority; default 0x1C) (optional)
- stack_size int Memory reserved for this task to be used as stack (default 0x10000) (optional)
trueto prevent the camera from turning off while running this task. (default false)
Yields execution of this script to other tasks and event handlers
(also from the same script).
FIXME: once a task executed yield(), other tasks or event handlers from the same script, that might interrupt the former, must not execute yield(). Otherwise, an error will be thrown to prevent memory corruption, camera lockup or worse.
The above limitation is a very dirty hack - a proper fix should be implemented by somebody familiar with multitasking in Lua. Help is more than welcome, as this topic is not exactly our cup of tea.
TODO: replace with msleep?
- duration int how long to sleep for in ms.