-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
My function call is such:
system.addTimer(0.1, timer1)
My C function follows at the end because of its size
The highlight of the code:
luaL_checktype(L, -2, LUA_TNUMBER);
luaL_checktype(L, -1, LUA_TFUNCTION);
ref1 = luaL_ref(L, LUA_REGISTRYINDEX);
duration = lua_tonumber(L, -2); // (duration is a double declared
earlier)
printf("Register duration: %f\n", duration);
The output of the print statement results in 0, and gdb has reported 0
as the value as well.
Even trying 0.5 results in the same thing. Am I doing something wrong
at all?
( full source code available upon request)
"Reportedly, he remarked to one of his Christian missionary friends:
'What you teach us to do is admirable, but what you teach us to
believe is foolish'."
- - Referring to King Mongkut of Siam
http://en.wikipedia.org/wiki/Mongkut
static int register_timer(lua_State *L)
{
GLView *view;
int ref1;
id ui;
double duration;
lua_pushlightuserdata(L, (void*)&Key);
lua_gettable(L, LUA_REGISTRYINDEX);
view = (GLView*)lua_touserdata(L, -1);
lua_pop(L, 1);
luaL_checktype(L, -2, LUA_TNUMBER);
luaL_checktype(L, -1, LUA_TFUNCTION);
ref1 = luaL_ref(L, LUA_REGISTRYINDEX);
duration = lua_tonumber(L, -2);
printf("Register duration: %f\n", duration);
ui = [NSNumber numberWithInt: ref1];
// [ui retain]; // apparantly timer does this on its own
NSTimer *timer = [NSTimer timerWithTimeInterval: duration
target: view
selector: @selector(performTimer:)
userInfo: ui
repeats: NO];
[[NSRunLoop currentRunLoop] addTimer: timer forMode:
NSDefaultRunLoopMode];
lua_pop(L, 2);
return 0;
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
iD8DBQFAwBCY0noMGorKkKgRAuDAAJ43qtYZHrZNsx3W3D89T9ye543hBACdEiy2
43IkvLTK4NJsPXh3W1iAemA=
=eo/k
-----END PGP SIGNATURE-----