lua-users home
lua-l archive

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


I'd like someone to point me to a sample source on how to push function on the stack.

For example, I can do following with a string:

const
char* code = "function
() print('hello world') end";

 lua_newtable(L); 
lua_pushstring(L,
"code"); 
 lua_pushstring(L,
code);
lua_settable(L, -3);


Later, when I try to retrieve the value, it returns string as is appropriate (I am serializing/deserializing it with Pluto):

...
lua_getfield(L2, -1,
"code");

int
t = lua_type(L2, -1);

...

How would one go about pushing code as a function? And also, how do I later retrieve it? A snippet of code would be greatly appreciated.

Thanks in advance,

Alex




 
____________________________________________________________________________________
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121