lua-users home
lua-l archive

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


Ken Paulson wrote:

> If I change the function to MyFunction (not within a table), then it
> works fine.  I'm sure it's just a dumb newbie mistake, so I'd
> appreciate if someone can point out what I'm doing wrong.

In C the procedure is the same as in a Lua script:
-  extract the function from the table
-  call the function

/* get (global) table */
lua_pushstring(L, "MyStuff");
lua_getglobal(L);

/* get function */
lua_pushstring(L, "MyFunction");
lua_gettable(L, -2);

/* drop table */
lua_remove(L, -2);

/* call function (0 args, 0 results) */
lua_call(L, 0, 0);

Bye,
Wim