lua-users home
lua-l archive

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


>I have a C function that loads a new lua file and runs the Init function in 
>it.  In my main loop, I just keep calling the Init function.  Is there any 
>danger in jumping into another file right in the middle of the function??  

No danger. I assume your main loop is something like:
	lua_dofile(L, filename)
	lua_call(L, "Init")
If so, this will call the last Init defined. If all files loaded contain an
Init function, than this will be called. If you're concerned that perhaps
a file does not contain an Init function but should, you can set Init to
nil before loading the file and test Init before calling it.

>Would it be better if I did:  lua_dostring( script, "return" ), before I 
>load the next file??

This code does nothing at all. A lua_dofile returns to the host program after
the chunk it contains ends.
--lhf