lua-users home
lua-l archive

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


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.

Lieven

----- Original Message ----- From: "Shmuel Zeigerman" <shmuz@actcom.co.il>
To: "Lua list" <lua@bazar2.conectiva.com.br>
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.

--
Shmuel