[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: using code from multiple files
- From: Shmuel Zeigerman <shmuz@...>
- Date: Fri, 16 Sep 2005 19:28:24 +0200
Lieven CI wrote:
I am trying to use two lua script files together, and let them call
functions from each other, but i can't get this working. I try to load
both scripts with the luaL_loadfile function, but when I load the second
script, I can't access anything from the first script any more (I have
the impression that it's still loaded, because the stack is larger than
when I only load the second file.
What is the best way to do this?
Assuming you are using the same lua_State in both calls
to luaL_loadfile, you must be able to access all the
global variables (including functions) defined in either
of the two scripts.
Didn't you forget to put in lua_call() after luaL_loadfile() ?
luaL_loadfile() only compiles the file and places the compiled
chunk onto the stack. You need to run it after that, using
lua_call or lua_pcall.
--
Shmuel