[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Problem using lua 5.0
- From: Vadim <sh-vadim@...>
- Date: Thu, 6 Nov 2003 15:31:07 +0200
Hello Chris,
Thursday, November 06, 2003, 3:06:48 PM, you wrote:
ckc> Hi there, I'm trying to reuse/redo a simple C++/LUA wrapper I wrote with Lua 4.0
ckc> My first problem is to be able to load and run a test script
ckc> I've replaced the old dofile with :
ckc> res=luaL_loadfile(m_luaState,fileName.c_str());
ckc> // Test res
ckc> res=lua_pcall(m_luaState, 0,0,0);
ckc> // Test res
ckc> The test script is a single line :
ckc> io.write("Hello from LUA")
ckc> Previously it was
ckc> print("Hello from LUA")
ckc> Both of them return an error :
ckc> attempt to index global `io' (a nil value)
ckc> or
ckc> attempt to index global `print' (a nil value)
ckc> I've tried to find a hint in the manual but may be I've missed it ?
ckc> Do I need to include a package to be able to output anything ??
ckc> Thanks
The code I use for the wrapper looks like:
lua_State *L = lua_open();
luaopen_base(L);
luaopen_table(L);
luaopen_io(L);
luaopen_string(L);
luaopen_math(L);
luaopen_debug(L);
luaopen_loadlib(L);
lua_dofile(L, fileName.c_str());
lua_setgcthreshold(L, 0); // collected garbage
lua_close(L);
Best regards,
Vadim mailto:sh-vadim@yandex.ru