[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Tolua and indexed array pointers
- From: "R. Frazier" <rtdoger@...>
- Date: Wed, 16 Mar 2005 21:25:35 -0500
How can I set the variables of a data structure using an indexed array
pointer?
Tolua doesn't seem to create such a binding?
///////////////////////////////////////////////
Package file for Tolua:
class vec3 {
public:
float x;
float y;
float z;
vec3() {};
vec3 & operator[] (int index) { return this[index]; };
};
// These are global variables in my program. vectors is allocated,
// num_vectors=100, vectors=new vec3[100]; before running Lua script.
extern int num_vectors;
extern vec3 *vectors;
///////////////////////////////////////////////
Lua test script:
function printf(...)
io.write(string.format(unpack(arg)));
end
-- x,y,z variables are NOT set - values DO NOT change
for i=1,num_vectors do
vectors[i].x = 10.0;
vectors[i].y = 10.0;
vectors[i].z = 10.0;
printf( "vectors: %f, %f, %f\n", vectors[i].x, vectors[i].y, vectors[i].z
);
end
//////////////////////////////////////////////////
Note that Tolua does allow me to do this:
v = vec3:new();
vectors[i] = v;
But it doesn't let me set x,y,z variables individually.
_________________________________________________________________
Take charge with a pop-up guard built on patented Microsoft® SmartScreen
Technology.
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
Start enjoying all the benefits of MSN® Premium right now and get the
first two months FREE*.