lua-users home
lua-l archive

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


hi

On Thu, May 01, 2008 at 09:28:35AM -0400, Aaron Saarela wrote:
...
> // get the foo module ready to go
> lua_dofile(state, "foo.lua");
> luaL_dostring(state, "foo.dosomething()");   // works fine
this accesses _G["foo]["dosomething"]

> But:
> 
> lua_getglobal(state, "foo.dosomething");
this tries to access _G["foo.dosomething"] which is not set

use a lua_getglobal(state, "foo") followed by a
lua_getfield for "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()
or maybe function dosomething() ?

>    print("Did something")
> end


regards
Klaus