lua-users home
lua-l archive

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


Hello..
I'm a Lua newbie, so, if this is to simple, i'm sorry :)
I was able to export a simple function to a Lua script :

static int test( lua_State* L)
{
	float n1 = lua_tonumber ( L , 1 ) ;
	printf("This is a test: %f \n", n1);
	return 0;
}


I'm able to register it like this :
lua_register(L, "test", test );

And run it sucessufely.

Now, i wanted to do the same but using other values than integers, 
something like this :


static vec3_t test( lua_State* L)
{
	vec3_t n1 = lua_tonumber ( L , 1 ) ;
	printf("This is a test: %f %f %f  \n", n1.v[0], n1.v[1], n1.v
[2]);
	return 0;
}

I understand lua_tonumber only works with integers, but looking at 
the lua.h file i find several lua_toXXX functions , like :

LUA_API lua_CFunction  lua_tocfunction (lua_State *L, int index);
LUA_API void	      *lua_touserdata (lua_State *L, int index);
LUA_API const void    *lua_topointer (lua_State *L, int index);

I have a feeling i must use one of those, but i don't find anywhere 
examples on how to do this..
Can you guys help me out on how to do it ?
thanks ,
Bruno