[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: lua_getglobal / lua_pcall - can't find my function
- From: "Aaron Saarela" <Aaron.Saarela@...>
- Date: Thu, 1 May 2008 09:28:35 -0400
Hi,
I have some lua functions I want to call from a C++ application. I use
lua_dofile to load the file. If I use lua_dostring to call a function it
works fine. However, when I use lua_getglobal/lua_pcall instead, my function
doesn't end up on the stack and pcall fails with a call to nil.
Here's an example of what I'm talking about:
// get the foo module ready to go
lua_dofile(state, "foo.lua");
luaL_dostring(state, "foo.dosomething()"); // works fine
But:
lua_getglobal(state, "foo.dosomething");
lua_pcall(state, 0, 0, 0);
// returns -1, err message indicates a call to nil
my foo.lua looks like:
module("foo", package.seeall)
function foo()
print("Did something")
end
Is there something I'm missing?
Thanks,
-Aaron