lua-users home
lua-l archive

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


----- Original Message -----
> Is there a simple method in lua for "linking" variables so as to make
> them visible in both the lua code and the C code.  For example Tcl
> includes a function Tcl_LinkVar(interp, name, ptr, type); which makes
> the C variable of the given type at the given location accessible
> through Tcl with the given name.

Simple datatypes does not live both places with Lua.. They exist only in the
global space or on the Lua stack. You should use
lua_getnumber(lua_getglobal("myVar")) and push/setglobal for accessing 'em.

Lua has the userdata datatype that holds a pointer so you can with that
datatype have some transparency.

/Erik