lua-users home
lua-l archive

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


If you want to do this, and make it feel natural to Lua, then it is a
bit of a pig to do: Create a table (T), assign it a fresh metatable
(MT), add an __index metamethod to MT which reads the value from the C
structure and then add a __newindex metatable to MT which writes the
value to the C structure.

2008/11/3 Robin-Vossen <robin-vossen@hotmail.com>:
>
> Hello,
>
> I am new to Embedding Lua to my C App.
> I understand that you can Embed your Functions you coded in Pure C by:
> luaL_reg(lua_State, "the character name of the function exposed to lua", the
> function in C)
> But, how can you Glue Variables like that?
> Like
> So I can put my config in Lua.
> And link it easily to:
> struct config {
>  int keyUp;
>  int keyLeft;
>  int keyRight;
>  int keyDown;
>
>  int volumeEffect;
>  int volumeMusic;
>
>  char playerName[9];
> } *cfg;
>
>
> Thanks.
>
> Robin
> --
> View this message in context: http://www.nabble.com/Bind-Variables--tp20288845p20288845.html
> Sent from the Lua - General mailing list archive at Nabble.com.
>
>