lua-users home
lua-l archive

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


> We're using tolua to make our 3d engine scriptable. All is ok, but
> now we have this problem: tolua doesn't generate a correct C source
> if in the input .H file there's a declaration of multidimensional
> array!
> 
> Example: we have in our cleaned header file
> 
> float Vertex[4][4];
> 
> The generated .C cannot be compiled because tolua thinks the second
> dimension is the value (or something like that).
> 
> And VC++ stops with "Cannot convert from 'float' to 'float[4]'"
> 
> What can we do?

You sometimes have to change things for toLua. 

float Matrix[16]; // [row*4 + col]

may work better. Or you could add an interface wrapper, toLua pkg:

typedef float Vertex;
$Vertex* vertex_create() { return malloc(Vertex*16); }
$void vertex_set(Vertex* v,int r,int c) {v[r][c]=v;}
$void vertex_get(Vertex* v,int r,int c) {return v[r][c];}
Vertex* vertex_create();
void vertex_set(Vertex* v,int r,int c);
void vertex_get(Vertex* v,int r,int c);

Just a quick example... hope you get the idea.

Regards,
Nick