lua-users home
lua-l archive

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


> > In short, how do I achieve something like this from the c api when I
> > create my state?
> >
> > -- script start
> > local MAX_LIMIT = 10
> >
> > -- lots of functions that use MAX_LIMIT everywhere
> >
> > -- end script
> >
> > (Short script huh!)
> >
> > Thanks for any help,
> 
> The C stack is where you would put local variables.
> 
> e.g.
> 
> int my_func (lua_State *L)
> {
>   lua_settop(L, max_arguments_allowed);
>   lua_pushinteger(L, 10); /* <-- MAX_LIMIT is at max_arguments_allowed
> + 1 */
>   /* do stuff with that value */
>   return 0;
> }
>

Thanks for the quick response, but I think you're misunderstanding my intentions.  What I want to do is add a "local" variable in C, for a lua script to access.

Thanks, Tom