lua-users home
lua-l archive

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

I defined (with the C API) a Vector object based on full user data.

	static Vec4 *Vget(lua_State *L, int i)
		if (luaL_checkudata(L,i,MYTYPE)==NULL) ERROR(MYTYPE);
		return (Vec4*)lua_touserdata(L,i);

Now, I'm interested to be able to index the 'x, y, z, t' coordinates with
numeric indexes (1,2,3,4). For instance :

	local v = Vec4(11,22,33,44)
	print(v.y) -- 22
	print(v) -- Vec4(0.27, 0.53, 0.80, 1.07)
	print(v[2]) -- 0.53 ???

	v[2]=22.22 -- ???
	print(v.y) -- 22.22

I don't see how to do that ?