lua-users home
lua-l archive

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


I'm fiddling with an embedded lua 5.0.2 interpreter for a little game I'm 
writing.  I can make the embedding work and such, but somehow I missed
something important.

It appears that lua puts values on the lua stack via "return" and I can 
pop those off the stack from C with no problem.  (Is there a better way
for lua to put values on the stack for C to get at?)

It's going the other way that I have trouble. I put values on the lua 
stack from C with lua_push(whatever), but how do I get at them from my lua 
script when it is run from within the C program?  I'm sort of expecting
something like perl's "$arg1=shift($_)"

BTW, I'm using "lua_dofile" from C to handle my lua script.  I'd really
like to split this into something that loads the lua file and then 
something that calls functions from that lua file later.  Is there
a way to do this from the C api so I don't have the cost of "lua_dofile"
every turn of the game?  

David