lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Sorry to respond to an old thread, but I thought I may as well
link my question to the previous one on the same issue. (Besides,
it proves I searched the archives before posting.)

--- In lua-l@y..., "Peter Prade" <prade@p...> wrote:
> > The matter is, is there any way to cancel a script execution
> > from within a C fucntion ?
> >
> > It would be something like:
> > LUA_endExecution( state )
> if you call lua_error(), script execution will stop:
> from the reference manual:
> = void lua_error (lua_State *L, const char *message);
> - This function never returns. If lua_error is called from a C function
> - that has been called from Lua, then the corresponding Lua execution
> - terminates, as if an error had occurred inside Lua code. 

This function would appear to terminate the whole script that is
being executed. I would like to know if there is a mechanism that
would let me temporarily exit - that is, pause execution of a Lua
script while preserving all the variables so that I can resume it
at a later stage. Basically, some simple context-switching. The idea
is that I can have a Wait function in a script that pauses script
execution for the specified time. Deciding when to continue the
script would be handled by the enclosing C++ program, but obviously
I need to know whether jumping out of the script while leaving
everything intact is even possible (and if so, if it's practical)

Ben Sizer.