You can run all of your lua_State and lua script in another thread. When a Lua script accesses functions you implement that need to change things in the main thread, use mutexes and other things to provide access to thread safe.
That way, you can easily turn on the Lua script or do something while your main thread can continue to work fine, however, it also requires that all your implemented functions access something that seems to be usually cares for the main thread (like graphics) to be aware of the thread.
source share