[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Registering a new function that wraps write(format())
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Thu, 21 Feb 2002 12:16:24 -0300
>Yes, but how would I do that from C?
How about this (tested)?
static int l_printf (lua_State *l) {
lua_getglobal(L,"format");
lua_insert(L,1);
lua_call(L,lua_gettop(L)-1,LUA_MULTRET);
lua_getglobal(L,"write");
lua_insert(L,1);
lua_call(L,lua_gettop(L)-1,LUA_MULTRET);
return lua_gettop(L);
}
lua_register(L,"printf",l_printf);
--lhf