[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Stack overflow
- From: lukey@... (Jens Hassler)
- Date: 02 May 2002 22:27:00 +0200
Hi there,
I think this is a typical beginner problem, so I hope someone can give me  
an answer :)
In my C(++) code of my game project I call a hook function defined in the  
Lua code with a handle to a game object (passed via a "tolua" function)  
each time when it is updated:
------------------------------------------------------------------------
int do_hook_object_update(Object *o)
{
  char func[50];
  int retcode = 0;
  sprintf(func, "hook_object_update", n);
  lua.getglobal(func);
  tolua_pushusertype(lua.get_state(),(void*)o,tolua_tag(lua.get_state(),"Object"));
  lua.call(1, 1);
  if (lua.isnumber(1)) ret = (int)lua.tonumber(1);
  return ret;
}
------------------------------------------------------------------------
I do this with other events, too (when object is dead, when it is hit, and  
so on), but the code above is called 60 times a second - and this is  
causing a stack overflow after a few seconds.
The lua functions are encapsulated inside a little C++ class I found  
somewhere, so don't mind :)
Am I doing something really nasty wrong?
Thx a lot,
Jens