lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>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