[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: CallBacks and Proto
- From: Rici Lake <lua@...>
- Date: Thu, 26 Oct 2006 11:44:27 -0500
On 26-Oct-06, at 11:32 AM, jdarling@eonclash.com wrote:
Rici, I don't quite get what you mean. Here is what I tried and it
didn't work (of course). I know how to create an entry into the
registry, but then how would I go about calling the method once I've
stored it?
Get it back out of the registry and call it.
A small sample would be great.
:EXISTING CODE:
var
pL : Plua_State;
callfunc : integer;
^^^^^^
function lua_astarCallback(X, Y, Fx, Fy: integer): integer;
begin
WriteLn('Calling cfunction: '+IntToStr(Integer(callfunc)));
lua_rawgeti(pL, LUA_REGISTRYINDEX);
^^^^^
-- CLIP --
// callfunc := lua_tocfunction(L, 9);
callfunc := luaL_ref(L, LUA_REGISTRYINDEX);
// Works because you know the stack has exactly nine things on it
// Otherwise, I'd use:
lua_pushvalue(L, 9);
luaL_reg(L, LUA_REGISTRYINDEX);
See the refman or PiL for more details