lua-users home
lua-l archive

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


I was wondering how you guys would handle reading a lot of lua variables in your lua code. The situation is this: I've got a table with a lot of fields of various types(numbers, strings,number vectors etc.) and I need to move that to a C struct. Doing it with metamethods would be complicated due to the fact that these tables are contained in an other table so I pass the whole thing to a C function and move it to the C struct from there. That works fine, the only problem is the resulting code. I have thought of two alternatives:

1)Using #define macros: This works but you end up with a lot of macros and then again some fileds require 'special' treatment, like setting a default value to the struct member if the lua field is nil, etc. So this isn't the best solution. 2) Straight C code: This works in all cases but you end up with a lot of _similar_ chunks of code so this isn't perfect either.

It's not that I can't live with this but I though I'd ask you anyway since some of you have a lot of experience with lua so you might know of a better way.

Dimitris