int
vec3add(lua_State *L) {
vector3* v=(vector3*)lua_touserdata(L,1);
vector3* v2=(vector3*)lua_touserdata(L,2);
*v+=*v2;
vector3* p;
p=(vector3*)lua_newuserdata(L,
sizeof(vector3));
p=v;
lua_pushvalue(L, 1);
return 1;
}
it turns out that lua_newuserdata, pushes itself onto the
stack anyway..
----- Original Message -----
Sent: Tuesday, May 13, 2003 11:58
PM
Subject: on the topic of userdata
ok this is what i want to do,
i've got a vector3 class similar to the vector3
tutorial in the example but using metatables of cause..
and what im trying to do is the __add for it, but
im not sure what to return, or push onto the stack i should say.
heres what im doing in c atm..
int
vec3add(lua_State *L) {
vector3* v=(vector3*)lua_touserdata(L,1);
vector3* v2=(vector3*)lua_touserdata(L,2);
*v+=*v2;
lua_pushlightuserdata(L, v);
return 1;
}
and in lua its just something like a=a+b;
anyway.. nothing happens. but this is all i could think
of, does anyone have any ideas on what i should do or what im doing
wrong.