6

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.

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

Try my lalarm library. It depends on alarm, which works in seconds, but can be easily changed to use ualarm if you have it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.