[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: using code from multiple files
- From: "Lieven CI" <lieven@...>
- Date: Wed, 21 Sep 2005 14:38:12 +0200
Thank you, this is indead what i forgot to do. I think I didn't really
understand the concept of chuncks yet, but it's getting more clear now.
----- Original Message -----
From: "Shmuel Zeigerman" <firstname.lastname@example.org>
To: "Lua list" <email@example.com>
Sent: Friday, September 16, 2005 7:28 PM
Subject: Re: using code from multiple files
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.