I need to asynchronously delay execution of a function in Lua by X milliseconds. Can this be done?
Given a simple JavaScript example:
setTimeout(function() {
alert('Hello world!');
}, 5000);
What’s the Lua equivalent? Coroutines look like they may help, but I’m not sure.
Lua itself does not include asynchronous event support. If you’re embedding Lua in something larger or using it with libraries, they may be able to provide callback support.