Original Post
I'm learning how to use lua together with c++ but I've run in to some problems where I got an access violation which I cant sort out and after searching and reading I must finally ask for help.
At the bottom at the lua_call I get the access violation and I'm using lua 5.2
[source lang="cpp"]static void spTr(cMap *m,int x, int y)
{
m->spawnTree(x,y);
}
static int spTrWra(lua_State *L)
{
int n = lua_gettop(L);
if(n!=3)
{
lua_pushstring(L, "Wrong number of arguments");
lua_error(L);
}
if(!lua_islightuserdata(L,1))
{
lua_pushstring(L, "wrong data type");
lua_error(L);
}
cMap* M = (cMap*)lua_touserdata(L,1);
int x = lua_tointeger(L,2);
int y = lua_tointeger(L,3);
spTr(M,x,y);
return 0;
}
[/source]
At the bottom at the lua_call I get the access violation and I'm using lua 5.2
[source lang="cpp"]static void spTr(cMap *m,int x, int y)
{
m->spawnTree(x,y);
}
static int spTrWra(lua_State *L)
{
int n = lua_gettop(L);
if(n!=3)
{
lua_pushstring(L, "Wrong number of arguments");
lua_error(L);
}
if(!lua_islightuserdata(L,1))
{
lua_pushstring(L, "wrong data type");
lua_error(L);
}
cMap* M = (cMap*)lua_touserdata(L,1);
int x = lua_tointeger(L,2);
int y = lua_tointeger(L,3);
spTr(M,x,y);
return 0;
}
[/source]